Write a program in c which will read and sum of all values an array
#include<stdio.h>
#include<conio.h>
main()
{
int a[100],i,n,sum=0;
printf("\n\tIT'S A PROGRAM TO FRINT & SUM OF ALL VALUES AN ARRAY\n");
printf("\n\tEnter the array size: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter the %d value: ",i);
scanf("%d",&a[i]);
sum+=a[i];
}
printf("\n\tThe sum is %d:\n",sum);
}
#include<stdio.h>
#include<conio.h>
main()
{
int a[100],i,n,sum=0;
printf("\n\tIT'S A PROGRAM TO FRINT & SUM OF ALL VALUES AN ARRAY\n");
printf("\n\tEnter the array size: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter the %d value: ",i);
scanf("%d",&a[i]);
sum+=a[i];
}
printf("\n\tThe sum is %d:\n",sum);
}
Carry on
ReplyDelete