Write A Program To Print The Following Output Using for in a For Loop. 1 3 5 7 9 11?

1

1 Answers

YASIR ARAFATH Profile
YASIR ARAFATH answered
Its very simple....I have used the 'C' language which is more lenient and best programming language for beginners.....
Program for displaying the Odd number(1,3,5,7,9,11.....);

#include<stdio.h>
#include<conio.h>

void main()
{
int n,odd;
printf("enter the numbers ");
scanf_s("%d",&n);
for(odd=0;odd<=n;odd++)
{
if(odd%2!=0)         // odd modulus 2 gives reminder that is not equal to zero
{

printf("n%d",odd);
}


}
printf("n");
getch();
}

Output: : Enter the number  :11

1
3
5
7
9
11

Just copy the above program and try it yourself....

Hope you got it..

Answer Question

Anonymous