Question

# 1- Write a program to print only the even numbers from 100 to 200 2- Write...

1- Write a program to print only the even numbers from 100 to 200
2- Write a program to print the odd numbers from 22 – 99
3- Write a program to calculate howe many even number from 10 to 120

1- Write a program to find only the even numbers for 12 different numbers
2- Write a program to find the odd numbers for 10 different numbers
3- Write a program to calculate howe many even number and how many odd number among 12 different numbers.

C program

Please find below the C programs for the given problems:

Screenshot is added for understanding the indentation along with a sample output of the porgam. Kindly comment in case of any query.

1. Program to print even numbers from 100 to 200:

PROGRAM: Please find below the commented c program to the problem:

#include <stdio.h>

int main()

{

int number; //integer number

printf("Below are the even numbers between 100 to 200(inclusive)\n");

for( number = 100; number <= 200; number ++){//repeat for all numbers between 100 to 200 (including 200)

if(number%2==0){//if current value of number is even

printf("%d\t", number);//print the number

}//end if

}//end for

return 0;

}

Screenshot:

Output:

2. Program to print odd numbers from 22-99

PROGRAM:

#include <stdio.h>

int main()

{

int number; //integer number

printf("Below are the odd numbers between 22 to 99:\n");

for( number = 22; number <= 99; number ++){//repeat for all numbers between 22 to 99

if(number%2!=0){//if current value of number is not even

printf("%d\t", number);//print the number

}//end if

}//end for

return 0;

}

Screenshot:

Output:

3. Program to count even numbers from 10 to 120:

PROGRAM:

#include <stdio.h>

int main()

{

int number; //integer number

int totalEven=0;//set total count of even numbers between 10 to 120 is 0

for( number = 10; number <= 120; number ++){//repeat for all numbers between 10 to 120

if(number%2==0){//if current value of number is even

totalEven++;//increment the count of total even numbers

}//end if

}//end for

printf("Total Even numbers between 10 to 120 are: %d", totalEven);

return 0;

}

Screenshot:

Output:

1. Find even numbers from 12 different numbers:

Logic: The program will ask user to enter 12 numbers and find the even numbers from the entered numbers.

PROGRAM:

#include <stdio.h>

int main()

{

int number[12]; //integer number array to hold 12 integers

printf("Enter 12 numbers: ");

for( int i = 0; i <12; i++){//read 12 numbers from user

scanf("%d", &number[i]);

}

printf("\nBelow are the even numbers among 12 numbers: \n");

for( int i = 0; i <12; i++){//read 12 numbers from user

if(number[i]%2==0){//if current value of number is even

printf("%d\t", number[i]);//print the even number

}//end if

}//end for

return 0;

}

Screenshot:

Output:

2. Program to print odd numbers for 10 different numbers

Logic: The program will ask user to enter 10 numbers and print the odd numbers from the entered numbers.

PROGRAM:

#include <stdio.h>

int main()

{

int number[10]; //integer number array to hold 10 integers

printf("Enter 10 numbers: ");

for( int i = 0; i <10; i++){//read 10 numbers from user

scanf("%d", &number[i]);

}

printf("\nBelow are the odd numbers in 10 entered numbers: \n");

for( int i = 0; i <10; i++){//read 12 numbers from user

if(number[i]%2!=0){//if current value of number is not even

printf("%d\t", number[i]);//print the odd number

}//end if

}//end for

return 0;

}

Screenshot:

Output:

3. Program to count even numbers from 10 to 120:

Logic: Program will ask user to enter 12 numbers at run time and then count even and odd numbers.

PROGRAM:

#include <stdio.h>

int main()

{

int number[12]; //integer number array to hold 12 integers

int evenCount = 0, oddCount = 0; //set total even and odds as 0 initially

printf("Enter 12 numbers: ");

for( int i = 0; i <12; i++){//read 12 numbers from user

scanf("%d", &number[i]);

}

for( int i = 0; i <12; i++){//read 12 numbers from user

if(number[i]%2==0){//if current value of number is even

evenCount++;//increment the count of even numbers

}//end if

else{

oddCount++;//increment the count for odd

}//end else

}//end for

printf("\nTotal Even numbers: %d", evenCount);

printf("\nTotal Odd numbers: %d", oddCount);

return 0;

}

Screenshot:

Output:

#### Earn Coins

Coins can be redeemed for fabulous gifts.