Question

C++ Code: PLEASE MAKE SURE THAT IS WORK -input any number between (0-100) • if the...

C++ Code: PLEASE MAKE SURE THAT IS WORK -input any number between (0-100) • if the number is odd, the program ends (do nothing) • if the number is even, output all the even numbers to 100 above the input Requirements: use if statements (minimum 1), and minimum 1 loop

0 0
Add a comment Improve this question Transcribed image text
Answer #1

below i written complete C++ code as per the requirement.

Please note the below program has been tested on ubuntu 16.04 system and compiled using g++ compiler. This code will also work on code blocks and visual studio.

-----------------------------------------------------------------------------------------------------------------------------------

Program:

------------------------------------------------------------------------------------------------------------------------------------

//header files

#include<iostream>

#include<stdlib.h>

using namespace std;

int main()

{

//variables

int num;

//accept a number

cout<<"Enter any number between 0-100: ";

cin>>num;

//if num is odd exit the code

if(num % 2 != 0)

{

exit(0);

}

else

{

cout<<"Printing the even numbers between "<<num<<" to "<<"100"<<endl;

for(int i = num; i<=100; i++)

{

if(i%2 == 0)

{

cout<<i<<" ";

}

}

}

cout<<endl;

return 0;

}


===============================================================

Sample Output:

================================================================

KIndly CHeck and Verify Thanks..!!!

Add a comment
Know the answer?
Add Answer to:
C++ Code: PLEASE MAKE SURE THAT IS WORK -input any number between (0-100) • if the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE DO BOTH OF THESE IN PYTHON!!! AND MAKE SURE THAT I CAN COPY THE CODE....

    PLEASE DO BOTH OF THESE IN PYTHON!!! AND MAKE SURE THAT I CAN COPY THE CODE. 1.) Exercise #1: Design and implement a program (name it PrintSum) that prompts the user for an integer values between 1 and 100. The program then uses a while loop to determine and print out the sum of all values between 1 and the entered value. The program rejects invalid input values with proper message such “Invalid Input. Try again.” Document your code and...

  • C languge please ! 1. Using the random number program, fill up an array with 100...

    C languge please ! 1. Using the random number program, fill up an array with 100 random numbers between -30 and 30 and display it. Find out how many of those numbers in the array are positive, negative, even and odd. Display the results. Make sure you cover the special case. Your entire code should have only 1 FOR loop. You will not receive any credit if you use more than 1 loop. (50 points - 5pts for commenting and...

  • Kaprekar C++ program a. Write a c++  code that takes any number between 0 and 9999 as...

    Kaprekar C++ program a. Write a c++  code that takes any number between 0 and 9999 as an input value, and returns the number of iterations it takes that number to reach 6174. Also, it needs to indicate if the number does not converge to 6174. Run the program with three different numbers of your choosing to show that it works. b. Write a second c++ code using the first. However, this new program will calculate how many iterations it takes...

  • this is written in c++ This code needs to work with any input to have the...

    this is written in c++ This code needs to work with any input to have the output with different numbers that are entered in. Please help me I need help with this problem. Thanks $ Section 4.4 is a part of assignment Lab21: Number Divisible by 4 and/or 5 Requirements: zylab Entire class due: 03/01/2020, 11:59 PM 4.4 Lab 21: Number Divisible by 4 and/or 5 Write a program that reads in an integer number. It should then determine if...

  • Question 4 (3 mark) : Write a Java program to ask the user to input an...

    Question 4 (3 mark) : Write a Java program to ask the user to input an integer number from the keyboard. The output should indicate whether it is positive, zero, or negative, an even number or an odd number. REQUIREMENTS • Your code should ask user to input an integer number, then decide its sign and parity based on this input. • Your code should use if-else statement. Your code must work exactly as the specification and the output should...

  • (java) Write a While loop that prompts the user for only even numbers. Keep prompting the...

    (java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...

  • Write code in c prototypes for ConvertDecimalToBinary and PrintBinary function ConvertDecimalToBinary0 pass in input decimal number...

    Write code in c prototypes for ConvertDecimalToBinary and PrintBinary function ConvertDecimalToBinary0 pass in input decimal number and array to hold binary number (8 cells 1 for each bit) In for loop, use right bitshift to divide by 2 In for loop, use a bitmask to determine if odd or even and ternary if to assign 1 or 0 to bit array function PrintBinary pass in binary number array Use for loop to print out each element of binary number array...

  • I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions...

    I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement: srand((unsigned int)time (NULL)); which will give the random number generator a random starting point. Note: srand and rand require the TIME.H (or iomanip) cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation. 2....

  • python la ab X, X Lab 7 Design and implement a Python program that uses a...

    python la ab X, X Lab 7 Design and implement a Python program that uses a while loop and selection statements to print the sum of the even numbers and the sum of the odd numbers (all integers) read from the keyboard. The sequence of numbers ends with a negative number: So, all numbers considered for printing the two sums are greater than or equal to 0. The sequence may be empty. Here is a possible interaction. Enter an integer:...

  • C++ please use only easy code and stdio.h because im just a beginner Description Write the...

    C++ please use only easy code and stdio.h because im just a beginner Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT