Sum of 'n' numbers
Sum of 'n' numbers in C Programming
Code:
#include<stdio.h>
int main(){
int a[10],n,sum=0,i;
printf("Enter the value of n\n");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("Enter the number\n");
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("The sum is %d",sum);
return 0;
}
Sum of 'n' numbers in C Programming
Code:
#include<stdio.h>
int main(){
int a[10],n,sum=0,i;
printf("Enter the value of n\n");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("Enter the number\n");
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("The sum is %d",sum);
return 0;
}
No comments