Question

Write a program that asks the user for an even integer, and asks again as long...

Write a program that asks the user for an even integer, and asks again as long as the given integer is not even (then it just thanks the user)

Homework Answers

Answer #1

SOURCE CODE IN C PROGRAMMING

#include <stdio.h>
void main()
{
int n;
printf("enter the even integer\t");
scanf("%d",&n);//read the number by the user
do
{
if(n%2==0)//check the number is even or not even
printf("even number\n");
else
break; //If the number not even then break and continue with the next statement after the loop
printf("enter even integer again\t");
scanf("%d",&n);//read the number again from the user
}
while(n%2==0);//loop run until the number is even
printf("\n not an even number \n thank you ");//Execute after the break statement if the number not even
}

SAMPLE OUTPUT

enter the even integer 8

even number

enter even integer again 10

even number

enter even integer again 12

even number

enter even integer again 17

not an even number

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 asks the user of a positive integer value. The program should use...
Write a program that asks the user of a positive integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1,2,3,4,…,50. using namespace std;
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
Write a program in C++ coding that asks the user to input an integer between 25...
Write a program in C++ coding that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2...
Write a program that asks the user to input an integer between 25 and 50, inclusive....
Write a program that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2 relational expressions. You...
write a C++ program that asks the user to enter 4 integer numbers then use if...
write a C++ program that asks the user to enter 4 integer numbers then use if ….. elseif ….. elseif ….. else to find the smallest number then display it.
Write a C++ Program that asks the user to type an Integer N and compute the...
Write a C++ Program that asks the user to type an Integer N and compute the u(N) defined by u(0) =3 u(n+1) = 3*u(n)+4
problem 1 Write a program that asks the user for an integer and then prints out...
problem 1 Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop. in c plus plus
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Write a program that asks the user to enter two integer numbers. the main function then...
Write a program that asks the user to enter two integer numbers. the main function then passes these numbers to a function named exp that calculates the multiplication of these numbers and print the exponential value of the result of multiplication
write a program that asks the User to enter a letter, then asks the user to...
write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT