#include<conio.h>
#include<stdio.h>
void main()
{
int i,n,a[100],sum;
clrscr();
printf("Enter no. of terms to add: ");
scanf("%d",&n);
printf("Enter %d terms to add:\n",n);
sum=0;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("Answer of ");
for(i=1;i<=n;i++)
{
if(i==1)
printf("%d ",a[i]);
else
printf("+ %d ",a[i]);
}
printf("= %d",sum);
getch();
}
CODING |
OUTPUT |
For any query or suggestion please comment below...
No comments:
Post a Comment