Sunday, April 9, 2023

find the sum of all arrey elements

 /*********** find the sum of all arrey elements *********/

#include "stdio.h"

int main (){

int i,sum=0,marks[1000],size;

printf ("enter the size of the arrey :");

scanf ("%i",&size);

printf ("enter all %d elements in the arrey :",size);

for (i=0;i<size;i++){

scanf ("%i",&marks[i]);

sum=sum+marks[i];

}

printf("the sum of the marks  is %d :",sum);

return 0;

}

                     output            output               output                 output           outptut

enter the size of the arrey :6

enter all 6 elements in the arrey :5

6

7

2

5

5

the sum of the marks  is 30 

No comments:

Post a Comment

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...