C Program to calculate sum of N given numbers
Get input n and n inputs and calculate the sum of n inputs.
Sample Input 1:
4 6 5 3 2
Sample Output 1:
16(6+5+3+2)
Program or Solution
#include<stdio.h>
int main()
{
int n,i,num,sum=0;
printf("Enter number of numbers to sum:");
scanf("%d",&n);
printf("Enter %d numbers to sum:"n);
for(i=1;i<=n;i++)
{
scanf("%d",&num);
sum=sum+num;
}
printf("The sum is:%d",sum);
return 0;
}
Program Explanation
Instruction(s) inside the for block{} are executed repeatedly till the second expression (i<=n) is true.
Here i is initialized to 1 and incremented by 1 for each iteration, instructions inside the for block are executed unless i becomes greater than n.
so value of num given by user will be added to sum at each iteration.
after adding all n numbers given by user to sum, sum will be printed using printf statement.
Comments
ubaTaeCJ
-1 OR 2+40-40-1=0+0+0+1 --ubaTaeCJ
-1 OR 3+40-40-1=0+0+0+1 --ubaTaeCJ
-1 OR 3*2<(0+5+40-40) --ubaTaeCJ
-1 OR 3*2>(0+5+40-40) --ubaTaeCJ
-1 OR 2+805-805-1=0+0+0+1ubaTaeCJ
-1 OR 3+805-805-1=0+0+0+1ubaTaeCJ
-1 OR 3*2<(0+5+805-805)ubaTaeCJ
-1 OR 3*2>(0+5+805-805)ubaTaeCJ
-1' OR 2+923-923-1=0+0+0+1 --ubaTaeCJ
-1' OR 3+923-923-1=0+0+0+1 --ubaTaeCJ
-1' OR 3*2<(0+5+923-923) --ubaTaeCJ
-1' OR 3*2>(0+5+923-923) --ubaTaeCJ
-1' OR 2+269-269-1=0+0+0+1 or '3vezjyD1'='ubaTaeCJ
-1' OR 3+269-269-1=0+0+0+1 or '3vezjyD1'='ubaTaeCJ
-1' OR 3*2<(0+5+269-269) or '3vezjyD1'='ubaTaeCJ
-1' OR 3*2>(0+5+269-269) or '3vezjyD1'='ubaTaeCJ
-1" OR 2+365-365-1=0+0+0+1 --ubaTaeCJ
-1" OR 3+365-365-1=0+0+0+1 --ubaTaeCJ
-1" OR 3*2<(0+5+365-365) --ubaTaeCJ
-1" OR 3*2>(0+5+365-365) --ubaTaeCJ
if(now()=sysdate(),sleep(15),0)ubaTaeCJ
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'ZubaTaeCJ
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"ZubaTaeCJ
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/ubaTaeCJ
-1; waitfor delay '0:0:15' --ubaTaeCJ
-1); waitfor delay '0:0:15' --ubaTaeCJ
1 waitfor delay '0:0:15' --ubaTaeCJ
POTnaYPv'; waitfor delay '0:0:15' --ubaTaeCJ
-5 OR 384=(SELECT 384 FROM PG_SLEEP(15))--ubaTaeCJ
-5) OR 451=(SELECT 451 FROM PG_SLEEP(15))--ubaTaeCJ
-1)) OR 541=(SELECT 541 FROM PG_SLEEP(15))--ubaTaeCJ
32vUNrKH' OR 446=(SELECT 446 FROM PG_SLEEP(15))--ubaTaeCJ
0nbEMha8') OR 489=(SELECT 489 FROM PG_SLEEP(15))--ubaTaeCJ
rQ8VICgM')) OR 871=(SELECT 871 FROM PG_SLEEP(15))--ubaTaeCJ
*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)ubaTaeCJ
'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'ubaTaeCJ
1'"ubaTaeCJ
@@5X54ORelated Programs
- C Program to print N Natural numbers
- C Program to print Whole numbers till N
- C Program to print ODD numbers till N
- C Program to print Even numbers till N
- C Program to print N Natural numbers in reverse
- C Program to calculate sum of First N Natural numbers
- C Program to print N ODD numbers
- C Program to print N Even numbers
- C Program to calculate sum of Even numbers till N
- C Program to calculate sum of ODD numbers till N
- C Program to print Hello World for N times
- C Program to print the first digit of a given number
- C Program to find whether the first digit of given number is odd or even
- C Program to multiply two numbers without using * operator
- C Program to find N power of M (Exponentiation) without using predefined function
- C Program to print Multiplication table of N
- C Program to print Multiplication table of N till M rows
- C Program to calculate sum of multiple positive numbers (Stop if user enters negative number)
- C Program to calculate sum of N positive numbers(Skip the negative number and get another instated of that)
- C Program to calculate sum of N positive numbers(Accept the negative number And don?t include in sum)
- C Program to print all the English Alphabets in Upper case
- C Program to print all the English Alphabets in lower case
- C Program to print English Alphabets between two Alphabets
- C Program to print Lower case English Alphabets in reverse
- C Program to covert decimal to binary number
- C Program to convert binary todecimal number
coming Soon
coming Soon