VR Indian Wanderers Youtube Facebook RSS Feed
Learn with Vikas Suhag
Program to calculate the sum of array elements by passing to a function
Mar 06, 2022   Vikas Suhag

#include <stdio.h>
float calculateSum(float num[]);
int main() {
  float result, num[] = {23.4, 55, 22.6, 3, 40.5, 18};
  // num array is passed to calculateSum()
  result = calculateSum(num);
  printf("Result = %.2f", result);
  return 0;
}
float calculateSum(float num[]) {
  float sum = 0.0;
  for (int i = 0; i < 6; ++i) {
    sum += num[i];
  }
  return sum;
}


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Travel Blog - VR Indian Wanderers
VR Indian Wanderers
Govt. Jobs Portal
Govt. Jobs Portal
Free Chart Maker
Make free animated Charts from .CSV
Search
Youtube Channel
Podcast
Subscribe to Email Updates
Connect With Us
VR Indian Wanderers Youtube Facebook RSS Feed
© 2024 Learn with Vikas Suhag. All Rights Reserved.