Discussion Forums

New User? Please read instructions!

C program to find sum of N numbers  

  RSS

thiyagarajan
Eminent Member
Joined: 5 months  ago
Posts: 26
27/01/2017 9:48 am  

C program to find sum of N numbers


ReplyQuote
admin
Eminent Member
Joined: 5 years  ago
Posts: 26
10/02/2017 10:05 am  

Below C program will find sum of N numbers

 

#include <stdio.h>

int main()

{

     int num, sum = 0, count, i;

     printf("Please enter how many numbers you want to add\n");

     scanf("%d", &num);

     printf("Please enter %d numbers one by one\n",num);

 

     for (count = 1; count <= num; count++)

     {

         scanf("%d",&i);

         sum = sum + i;

     }

     printf("Sum of entered numbers = %d\n",sum);

     return 0;

}

 

Output:

Please enter how many numbers you want to add

3

Please enter 3 numbers one by one

40

20

10

Sum of entered numbers = 70


ReplyQuote
  
Working

Please Login or Register

Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!