print the nth natural odd number using a do-while loop.


QUESTION:- print the odd number up to user input using a do-while loop. 


#include <stdio.h>

#include <conio.h>

void main()

{

    int no = 1;

    printf("the odd numbers less than 10 are: \n");

    printf("1 \n");

    do
    {

        no = no + 2;

        printf("%d  \n"no);

    } while (no < 10);

    getch();
}

 

OUTPUT
the odd numbers less than 10 are: 
1   
3   
5   
7   
9   
11


Follow our page for regular updates.

0 Comments