Program to calculate the sum of given number using array
Program to calculate the sum of given number using array
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[100];
int i,n,sum=0;
clrscr(); /* clrscr() function is work only TURBO C/C++ compiler .
It will not work in CODE BLOCKS compiler. */
printf("How many number you want to enter? ");
scanf("%d",&n);
printf("enter the array elements: ");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
printf("your entered array is : ")
for (i=0;i<n;i++)
{
printf("%5d",arr[i]);
sum=sum+arr[i];
}
printf("\nsum of array elements are: %d",sum);
getch();
}
Comments
Post a Comment