Advertisement
Guest User

s

a guest
Dec 9th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int i, n;
  6.    
  7.     /* Input upper limit from user */
  8.     printf("Print odd numbers till: ");
  9.     scanf("%d", &n);
  10.  
  11.     printf("All odd numbers from 1 to %d are: \n", n);
  12.  
  13.     /* Start loop from 1 and increment it by 1 */
  14.     for(i=1; i<=n; i++)
  15.     {
  16.         /* If 'i' is odd then print it */
  17.         if(i%2!=0)
  18.         {
  19.             printf("%d\n", i);
  20.         }
  21.     }
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement