Turn Desktop View Off
by Dinesh Thakur Category: Control Structures

In this example, a for loop is set up with values of loop variable num from m to n. The if statement is executed for each value of num and if nums an odd number (num%2 equals 1), it is printed using the printf statement. The output of this code is given below for m= 20 and n=40.

#include <stdio.h>

void main()

{

    int num,m =20,n=40;

    clrscr();

    printf("Print Odd Numbers in a given range m to n:\n");

    for (num = m; num <= n; num++)

        {

               if (num % 2 == 1)

                  printf ("%d ", num);

         }

                getch();

}

         C Program Print Odd Numbers in a given range m to n



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article