## C Program to print N ODD numbers

### Description

```Get input n and print n odd numbers.
Input:
7
Output:
1 3 5 7 9 11 13```

### Solution

```#include<stdio.h>
int main()
{
int n,i,j;
printf("Enter a number:");
scanf("%d",&n);
printf("First %d odd numbers are:\n",n);
for(j=1,i=1;j<=n;i=i+2,j++)
{
printf("%d ",i);
}
return 0;
}```

### Explanation

```Instruction(s) inside the for block{} are executed repeatedly till  the second expression (j<=n) is true.

Here i and j are initialized to 1 and i is incremented by 2 and j is incremented by 1. for each iteration, instructions inside the for block are executed unless j becomes greater than n. so value of i (1,3,5,7.....) (n odd numbers) in each iteration will be printed using printf statement.
```

#### Author - Ramesh P Natarajan

Learner, Professor, Technology Trainer, Software Developer and Content Marketer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

### Interesting Pattern Programs: for more Patterns

```Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution```
```Input:
5
Output:
*
***
*****
*******
*********
*******
*****
***
*Solution```
```Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution```
```Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution```
```Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution```
```Input:
5
Output:
*********
*******
*****
***
*
***
*****
*******
*********Solution```