C program to add n numbers
Posted by Spider on 5:56 AM
#include <stdio.h> int main() { int n, sum = 0, c, value; printf("\nEnter the number of integers you want to add :: ");
scanf("%d", &n); printf("\nEnter %d integers :: ",n);
for (c = 1; c <= n; c++) { scanf("%d",&value); sum = sum + value; } printf("\nSum of entered integers :: %d",sum);
return 0; }
/*
Output ::
Enter the number of integers you want to add :: 5Enter 5 integers :: 5 4 3 2 1Sum of entered integers :: 15
*/
Tags
C Basics