Preview:
#include <stdio.h>
#include <stdlib.h>
/*Exercise 3
Write a C code that will ask the user to enter 10 numbers, store them in an array. Then calculate the sum of elements in the array and print the result on the screen.*/

//calculate sum of all element in the array

int main() {
   int arr[10];
   int i,j;
   for(int i=0;i<=9;i++)
   {
       printf("please enter an elemet %d: ", i+1);
       scanf("%d",&arr[i]);
   }
   int sum=0;
   for(int i=0;i<=9;i++)
   {
       sum=sum+arr[i];
   }
   printf("the sum of all element in the array are: %d\n",sum);

    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter