Input ‘N’ numbers into array and display sum in C program

/*input N and add*/
#include<stdio.h>
main()
{
int n, sum = 0, i, array[100];
printf("Enter the number of integers you want to add=");
scanf("%d", &n);
printf("\n\nEnter %d integers \n\n", n);
for(i = 0; i < n; i++)
{
scanf("%d", &array[i]);
sum =sum+array[i];
}
printf("\n\nSum = %d\n\n", sum);
}

Leave a Reply

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

Enter Captcha Here : *

Reload Image