Advertisement
saira12tabassum19

Untitled

Jul 1st, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. /*
  2.  
  3. * C program to find the sum of 'N' natural numbers
  4.  
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9.  
  10.  
  11. void main()
  12.  
  13. {
  14.  
  15. int i, num, sum = 0;
  16.  
  17.  
  18.  
  19. printf("Enter an integer number \n");
  20.  
  21. scanf ("%d", &num);
  22.  
  23. for (i = 1; i <= num; i++)
  24.  
  25. {
  26.  
  27. sum = sum + i;
  28.  
  29. }
  30.  
  31. printf ("Sum of first %d natural numbers = %d\n", num, sum);
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement