Yasir's Blog
Pages
About Me
C Programs
Java Programs
ML
Contact Me
Sitemap
Privacy Policy
Home
»
C Programs
»
C Program to Add n numbers
Sunday, 1 January 2017
C Program to Add n numbers
Program:
This program is saved as Add.c
#include
int main() { int n,sum=0,c,value; printf("Enter the number of integers you want to add : "); scanf("%d",&n); printf("Enter %d integers\n",n); for(c = 1;c <= n;c++) { scanf("%d",&value); sum = sum + value; //adding each no. in sum } printf("Sum of entered integers = %d\n",sum); return 0; }
Output:
Enter the number of integers you want to add : 5 Enter 5 integers 45 15 28 3 16 Sum of entered integers = 107
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment