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)
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
Get Answers For Free
Most questions answered within 1 hours.