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

Homework Answers

Answer #1

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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program that takes n integer numbers from the user, and then counts the number...
Write a program that takes n integer numbers from the user, and then counts the number of even numbers and odd numbers and print them to the screen. Sample Output: Enter how many numbers you have: 10 Enter the 10 numbers: 1 3 19 50 4 10 75 20 68 100 The number of even numbers is: 6 The number of odd numbers is: 4 (( in java ))
1) Write a C program to print the prime numbers from 1 to 100. (A prime...
1) Write a C program to print the prime numbers from 1 to 100. (A prime integer is any integer that can be divided evenly only by itself and 1) Requirement: Use an array to take the number from 1 to 100 and another array to take the prime number.
Assembler lanaguage program   The program is to prompt the user to enter a number between 2...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2 and 100. Reject any invalid user inputs and terminate the program if invalid inputs are entered. Print each even number from 2 to the user entered number. Sum these even numbers and print the sum. Print each odd number from 1 to the user entered number. Sum these odd numbers and print the sum. Exit the program when the output is complete. The output...
write a C++ program that display a prime numbers between 1 and 100 number. Plase print...
write a C++ program that display a prime numbers between 1 and 100 number. Plase print the remaining primes by “dots” For gexample The output should appear like The prime numbers between 1 and 100 are: 1, 2, 3, 5, 7, .........
Prime Numbers) Write a program to calculate and print a list of all prime numbers from...
Prime Numbers) Write a program to calculate and print a list of all prime numbers from 1 to 100. C programming
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Write a program in C that calculate and print the summation of odd numbers between 1-15...
Write a program in C that calculate and print the summation of odd numbers between 1-15 and then find the average of the summation of these numbers, please use double data type to declare all variables. Use for or do/while loop, please explain the steps aswell
Using for loops: - write a Java program that adds numbers between 1 to 100 and...
Using for loops: - write a Java program that adds numbers between 1 to 100 and prints the result. - write a Java program that adds odd numbers between 1 to 100 and prints the result - write a Java program that averages even numbers between 5 to 30 and prints the result
Write a script that will generate seven random integers in the range [-100:200] inclusive and then...
Write a script that will generate seven random integers in the range [-100:200] inclusive and then print the value of each integer and whether it is positive or negative and whether it is even or odd. An output from this program might be: -57 is negative and odd. 26 is positive and even. If zero is one of the random integers generated, remember that zero is even and neither negative or positive. Hint: even numbers are divisible by 2 with...
Write a program to calculate the sum of all prime numbers between 100 and 200, including....
Write a program to calculate the sum of all prime numbers between 100 and 200, including. A prime number is a natural number greater than 1 and can only be divided by 1 and itself. For example, 5 is a prime number because 5 can only be divided by 1 and 5. we are currently using cin/cout, for /while loops