028. Write a Program to print first n odd numbers in C language

#include<stdio.h>
#include<conio.h> 
main()
{
  int i=1,n;
  clrscr();
  printf("Enter n : ");
  scanf("%d",&n);
  while(i<=n)
  {
	   printf("%d\t",i);
	   i=i+2;
  }
  getch();
}

2 thoughts on “028. Write a Program to print first n odd numbers in C language

  1. Here i should be initilaized to 1.
    here i is initialised to 2
    let n=10
    2<10
    print 2
    but 2 is not an odd number.
    so this should be the case
    i=1 initially
    n=10
    1<10
    print 1
    1 is an odd number

Leave a Reply

Your email address will not be published. Required fields are marked *