ab_tanjir

Untitled

Sep 28th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. // summation of nth
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int main(){
  7.     int n, incriment, sum = 0, i;
  8.     scanf("%d", &n);
  9.  
  10.     if(n%2 == 0){
  11.         sum = 2;
  12.     }else{
  13.         sum = 1;
  14.     }
  15.  
  16.  
  17.     for(i = 1; i<=n; i++){
  18.         sum = sum + 2;
  19.     }
  20.  
  21.     printf("Summation is : %d", sum);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment