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+1
ubaTaeCJ
-1 OR 3+805-805-1=0+0+0+1
ubaTaeCJ
-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'Z
ubaTaeCJ
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
ubaTaeCJ
(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
@@5X54O