C Online Compiler
Example: C Program to Find Sum of N Numbers using For loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find Sum of N Numbers using For loop #include <stdio.h> int main() { int s, i, sum = 0; // s - To store the size of the array printf("----Enter the size of the array----\n"); scanf("%d", &s); int x[s]; // x - To store the array element to store the input numbers printf("\n\n----The sum of the %d input numbers----\n\n", s); for(i = 0; i < s; i++) { scanf("%d", &x[i]); sum += x[i]; } printf("\n\nThe total sum is: %d", sum); return 0; }
6 34 54 24 53 24 67
Output
Clear
ADVERTISEMENTS