068. Write a program to accept a number n from user and then accept n array elements from user and print addition of those n array elements in C language

#include<stdio.h>
#include<conio.h>
main()
{
 int n,i,a[20],sum=0;
 clrscr();
 printf("Enter number...");
 scanf("%d",&n);
 printf("Enter array elements :\n" );
 for(i=0;i<n;i++)
	{
		printf("Enter element %d : ",i+1);
		scanf("%d",&a[i]);
	}
 
 for(i=0;i<n;i++)
	sum=sum+a[i];
 printf("\nSum of given array elements is : %d",sum);
 getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *