C Program to Print First n Odd Numbers using For Loop

Write a Program to Print First n Odd Numbers using For Loop

// C Program to Print First n Odd Numbers using For Loop

#include <stdio.h>

int main()
{
	int n;

	printf("Enter Number :--> ");
	scanf("%d",&n);

	int i = 1, count;

	printf("First %d Odd Numbers :--> ", n);

	for(count = 0; count < n; i++)
	{
		if(i%2 != 0)
		{
			printf("%d ",i);
			count++;
		}
	}
	return 0;
}

Output:

Enter Number :--> 8
First 8 Odd Numbers :--> 1 3 5 7 9 11 13 15

≪ Previous | Next ≫