Advertisement
princesarkerjoy

sum of nth number

May 27th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.22 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, i ,sum = 0;
  6.  
  7.     scanf("%d",&n);
  8.  
  9.     for( i = 0; i <= n ; i++)
  10.     {
  11.         sum = sum + i;
  12.     }
  13.  
  14.     printf("Sum of %d number is : %d\n",n,sum);
  15.  
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement