Q:

C Program to Print Odd Numbers in a Given Range

belongs to collection: C Programming on Numbers

0

C Program to Print Odd Numbers in a Given Range

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Below mentioned C program allows the user to enter the minimum and maximum value. Like the above-mentioned program, this C program will print odd numbers in a given range.

#include<stdio.h>
int main()
{
    int i, min, max;
    printf("\n Please Enter the min Limit Value :  ");
    scanf("%d", &min);
    printf("\n Please Enter the max Limit Values :  ");
    scanf("%d", &max);
    if ( min % 2 == 0 )
    {
        min++;
    }
    printf("\n Even Numbers between %d and %d are : \n", min, max);
    for(i = min; i <= max; i= i+2)
    {
        printf(" %d\t", i);
    }
    return 0;
}

Output:

Please Enter the min Limit Value: 5
Please Enter the max Limit Values: 10

Even Numbers between 5 and 10 are :
5 7 9

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming on Numbers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to find whether a given number is prime number... >>
<< C Program to Print Odd Numbers from 1 to N...