0
What are the mistakes in this code ? Please help
/* C program to find sum of all array elements*/ #include<stdio.h> #define max_size 100 int main() { int n,i,sum=0; int arr[ 5]; //input array size printf ("Enter size of array:"); scanf("%d",&n); //input array elements printf ("Enter elements of array:"); for(i=0;i<n;i++) { scanf("%d",arr[i]); } printf ("Summation of elements in array:"); for(i=0;i<n;i++) { sum+=arr[i]; printf("%d",arr[i]); } printf ("\n"); return 0; }
2 Réponses
+ 1
The future is now thanks to science thank you so much
0
You forgot to add the "&" in the scanf inside the loop.
Also since you need to print the sum you should print the value of the sum, not the arr elements.
https://code.sololearn.com/cb59yDhMTKrw/?ref=app