Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

write a program to calculate the sum of arry in a function.

0 votes
asked Apr 11, 2018 by anonymous
in math:

-int x[10]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

-sum=x[0] +x[1] +x[2] +x[3] +x[4] +x[5] +x[6] +x[7] +x[8] + x[9];

1 Answer

0 votes
answered Apr 11, 2018 by anonymous
#include <stdio.h>

int main ()
{
  int x[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  int i;
  int sum = 0;
  for (i = 0; i < 10; i++)
    sum += x[i];

  printf ("Sum=%d", sum);

  return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...