RahulShaw

Series No. 1

Mar 3rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5.     int n;
  6.     printf("Enter the number of terms:\n");
  7.     scanf("%d", &n);
  8.     printf("Printing the %d terms\n", n);
  9.  
  10.     for(int i = 1; i <=n; i++) {
  11.         if(i%2 != 0) {
  12.             printf("%d", i);
  13.             if(i < n) {
  14.                 printf("%c", ',');
  15.             }
  16.         }else {
  17.             printf("%d", i * -1);
  18.             if(i < n) {
  19.                 printf("%c", ',');
  20.             }
  21.         }
  22.     }
  23. }
Add Comment
Please, Sign In to add comment