Write a program that contains a menu and the following elements: SECTIONS Greate
ID: 3673187 • Letter: W
Question
Write a program that contains a menu and the following elements: SECTIONS Greater than, Less than or equal . Get two integer values from the user If the first is greater than the second, print the message If the first is less than the second, print the message in .If the numbers are equal, print the message in words. in words words Evenly Divisible Get two integer values from the user. . Test these two numbers to determine if the first is evenly divisible by the second Display and appropriate message at the terminal. Display the result of dividing the first integer by the second with the remainder SECTIONS Letter Grades .Get an integer grade from the user . Use “if-else" statements to Print the letter grade for the grade Letter Grades At: 97 to 100 A: 94 to 96 A-: 90 to 93 B+: 87 to 89 B: 84 to 86 B 80 to 83 C+: 77 to 79 C: 74 to 76 C 70 to 73 D: 65 to 69 F: Below 65Explanation / Answer
#include<stdio.h>
#include<conio.h>
main()
{
int choice,firstnumber,secondnumber,secondchoice;
int quotient,remainder;
int marks,digit;
point:
printf(" Choose Any one Section ");
printf("Press 1 for Section A: Greater, Less than, Equal to & Evenly Divisible ");
printf("Press 2 for Section B: Letter Grades ");
printf("Press 3 for Section C: Digits in Word ");
printf("Press 0 for Exit ");
scanf("%d",&choice);
if(choice==1)
{
printf(" Press 1 for Greater, Lesser & Equal ");
printf("Press 2 for Evenly Divisible ");
scanf("%d",&secondchoice);
switch(secondchoice)
{
case 1:
printf(" To find Greater, Less than and Equal to ");
printf("Please Enter first number: ");
scanf("%d",&firstnumber);
printf("Please Enter second number: ");
scanf("%d",&secondnumber);
if(firstnumber>secondnumber)
printf(" %d is greater than %d",firstnumber,secondnumber);
else if(firstnumber<secondnumber)
printf(" %d is greater than %d",secondnumber,firstnumber);
else
printf(" %d is equal to %d",firstnumber,secondnumber);
break;
case 2:
printf(" To find Evenly Divisible ");
printf("Please Enter first number: ");
scanf("%d",&firstnumber);
printf("Please Enter second number: ");
scanf("%d",&secondnumber);
quotient=firstnumber/secondnumber;
remainder=firstnumber%secondnumber;
if(remainder==0)
printf(" %d is evenly divisible by %d ",firstnumber,secondnumber);
else
printf(" %d is quotient and %d is remainder",quotient,remainder);
break;
}
goto point;
}
if(choice==2)
{
printf(" Letter Grades ");
printf("Please Enter Student's marks out of 100 ");
scanf("%d",&marks);
if(marks>=97 && marks<=100)
printf("Your Grade is A+");
else if(marks>=94 && marks<=96)
printf("Your Grade is A");
else if(marks>=90 && marks<=93)
printf("Your Grade is A-");
else if(marks>=87 && marks<=89)
printf("Your Grade is B+");
else if(marks>=84 && marks<=86)
printf("Your Grade is B");
else if(marks>=80 && marks<=83)
printf("Your Grade is B-");
else if(marks>=77 && marks<=79)
printf("Your Grade is C+");
else if(marks>=74 && marks<=76)
printf("Your Grade is C");
else if(marks>=70 && marks<=73)
printf("Your Grade is C-");
else if(marks>=65 && marks<=69)
printf("Your Grade is D");
else if(marks<65)
printf("Your Grade is F");
else
printf("You have to enter marks between 0 to 100");
goto point;
}
if(choice==3)
{
printf(" 2 Digits in words ");
printf(" Please Enter Two Digit Number ");
scanf("%d",&digit);
quotient=digit/10;
remainder=digit%10;
if(quotient>9)
printf("Please enter two digits only ");
else if(remainder==0)
{
if(quotient==1)
printf("Ten");
if(quotient==2)
printf("Twenty");
if(quotient==3)
printf("Thirty");
if(quotient==4)
printf("Forty");
if(quotient==5)
printf("Fifty");
if(quotient==6)
printf("Sixty");
if(quotient==7)
printf("Seventy");
if(quotient==8)
printf("Eighty");
if(quotient==9)
printf("Ninety");
}
else
{
switch(quotient)
{
case 1: printf("One ");
break;
case 2: printf("Two ");
break;
case 3: printf("Three ");
break;
case 4: printf("Four ");
break;
case 5: printf("Five ");
break;
case 6: printf("Six ");
break;
case 7: printf("Seven ");
break;
case 8: printf("Eight ");
break;
case 9: printf("Nine ");
break;
case 0: break;
}
switch(remainder)
{
case 1: printf("One ");
break;
case 2: printf("Two ");
break;
case 3: printf("Three ");
break;
case 4: printf("Four ");
break;
case 5: printf("Five ");
break;
case 6: printf("Six ");
break;
case 7: printf("Seven ");
break;
case 8: printf("Eight ");
break;
case 9: printf("Nine ");
break;
case 0: break;
}
}
goto point;
}
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.