Sample C Program 4 - Page 1
#include
int main() {
int n, i, sum = 0;
printf("Enter a number: ");
scanf("%d", &n;);
for(i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d numbers: %d\n", n, sum);
return 0;
}
Explanation:
This page demonstrates a simple C program example. It includes the code and explanation of how
it works. Each document is extended to multiple pages for demonstration purposes.
Sample C Program 4 - Page 2
#include
int main() {
int n, i, sum = 0;
printf("Enter a number: ");
scanf("%d", &n;);
for(i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d numbers: %d\n", n, sum);
return 0;
}
Explanation:
This page demonstrates a simple C program example. It includes the code and explanation of how
it works. Each document is extended to multiple pages for demonstration purposes.
Sample C Program 4 - Page 3
#include
int main() {
int n, i, sum = 0;
printf("Enter a number: ");
scanf("%d", &n;);
for(i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d numbers: %d\n", n, sum);
return 0;
}
Explanation:
This page demonstrates a simple C program example. It includes the code and explanation of how
it works. Each document is extended to multiple pages for demonstration purposes.
Sample C Program 4 - Page 4
#include
int main() {
int n, i, sum = 0;
printf("Enter a number: ");
scanf("%d", &n;);
for(i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d numbers: %d\n", n, sum);
return 0;
}
Explanation:
This page demonstrates a simple C program example. It includes the code and explanation of how
it works. Each document is extended to multiple pages for demonstration purposes.
Sample C Program 4 - Page 5
#include
int main() {
int n, i, sum = 0;
printf("Enter a number: ");
scanf("%d", &n;);
for(i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d numbers: %d\n", n, sum);
return 0;
}
Explanation:
This page demonstrates a simple C program example. It includes the code and explanation of how
it works. Each document is extended to multiple pages for demonstration purposes.