fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int i, n, sum=0;
  6.  
  7. /* Input size of the array */
  8. int num[10];
  9.  
  10. printf("Enter size of the array: ");
  11. scanf("%d", &n);
  12.  
  13. /* Input elements in array */
  14. printf("Enter %d elements in the array: \n");
  15. for(i=0; i<n; i++)
  16. {
  17. scanf("%d", &num[i]);
  18. }
  19.  
  20. for(i=0; i<n; i++)
  21. {
  22. sum = sum + num[i];
  23. }
  24. printf("Sum of entered number is: %d\n", sum);
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 4288KB
stdin
10
10
10
10
10
10
10
10
10
10
stdout
Enter size of the array: Enter 1 elements in the array: 
Sum of entered number is: 90