One dimensional array example
/* program to calculate sum of 10 numbers in an array */
#include<stdio.h>
main()
{
int array[10],j,sum=0;
clrscr();
printf("\nEnter 10 numbers :");
for(j=0;j<=9;j++)
scanf("%d",&array[j]);
printf("\ncalculating the sum of elements in the array:");
for(j=0,sum=0;j<=9;j++)
sum=sum+array[j];
printf("\nsum of the elements of the array =%d",sum);
getch();
}
0 comments:
Post a Comment