1.)Write a program that requests the user to enter the number100.If the user ent
ID: 3608657 • Letter: 1
Question
1.)Write a program that requests the user to enter the number100.If the user enters something else, keep asking the user toenter 100!Print a thank you message once they have entered 100.2.)Write a switch statement to print out "Odd" or "Even" for eachinteger that is typed on the keyboard depending on whether theinteger is odd or even. Only integers from 0 to 9 can be typed onthe keyboard.
3.)Write a switch statement to print out Yes or No depending onwhether you type "Y" (or "y") or "N" (or "n") on the keyboard. Ifany other letter is typed, the program should print "Invalid entry:Type "Y" or "N" ".
4.)Write a program using the "while" loop statement to compute anddisplay the cubes (x3) of all numbers from 10 to 20. The displayshould look like this:
1
8
27
64
Explanation / Answer
please rate - thanksa)
#include <stdio.h>
#include <conio.h>
int main(void)
{int n;
do
{printf("Enter a number 100: ");
scanf("%d",&n);
}while(n!=100);
printf("THANK YOU!!");
getch();
}
b)
#include <stdio.h>
#include <conio.h>
int main(void)
{int n;
do
{printf("Enter a number between 0 and 9: ");
scanf("%d",&n);
}while(n<0||n>9);
switch(n%2)
{case 0: printf("Even ");
break;
case 1: printf("Odd ");
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.