/ Undifined / 12 - WAP to print the sum of all numbers up to a given number

12 - WAP to print the sum of all numbers up to a given number

WAP to print the sum of all numbers up to a given number.
#include <stdio.h>
 
int main()
{
   int n, sum = 0, c, value;
 
   printf("Enter the number of integers you want to add\n");
   scanf("%d", &n);
 
   printf("Enter %d integers\n",n);
 
   for (c = 1; c <= n; c++)
   {
      scanf("%d", &value);
      sum = sum + value;
   }
 
   printf("Sum of entered integers = %d\n",sum);
 
   return 0;
}
Output 
Enter the number of integers you want to add 3
 
Sum of entered integers = 14

about author

Blogger Sens it website about blogger templates and blogger widgets you can find us on social media
Previous Post :Go to tne previous Post
Next Post:Go to tne Next Post

No comments:

Post a Comment