Q:

C Program to Print Even Numbers in a Given Range

belongs to collection: C Programming on Numbers

0

C Program to Print Even 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 Minimum and maximum value. After that like the above-mentioned program, this C program will print even 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 6 and 10 are :
6 8 10

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
C Program to Print Odd Numbers from 1 to N... >>
<< C Program to Print Even Numbers from 1 to N withou...