Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * C program to find the sum of 'N' natural numbers
- */
- #include <stdio.h>
- void main()
- {
- int i, num, sum = 0;
- printf("Enter an integer number \n");
- scanf ("%d", &num);
- for (i = 1; i <= num; i++)
- {
- sum = sum + i;
- }
- printf ("Sum of first %d natural numbers = %d\n", num, sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement