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
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.
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....
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 C program that when you type in five numbers, it will print the number...
Write a C program that when you type in five numbers, it will print the number from the smallest one to the largest one.(if you type in 2, 1, 3, 5, 4, the output will be 1, 2, 3, 4, 5 ) You may need more than one function to complete this mission.
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
Write an R code to print out all even numbers from the following numbers list in...
Write an R code to print out all even numbers from the following numbers list in the same order they are received. Write the code so it does not print any numbers that come after 83. numbers = [951, 40, 84, 51, 60, 69, 48, 19, 61, 85, 98, 50, 72, 47, 44, 61, 83, 65, 41, 51, 63, 61, 65, 75, 21, 30, 84, 92, 23]
PYTHON 3 Write a program that prints the count of all prime numbers between A and...
PYTHON 3 Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 21212 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules: You should first...