Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
83 views1 page

MCS 011 - Q2 Program

This C program provides a menu-driven interface that allows the user to select one of four integer math operations: 1) subtract two numbers, 2) compare two numbers and output the smaller, 3) test if a number is odd or even, or 4) quit the program. The program uses switch statements to evaluate the user's selection and call the corresponding operation code, then loops back to display the menu again until the user chooses to quit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views1 page

MCS 011 - Q2 Program

This C program provides a menu-driven interface that allows the user to select one of four integer math operations: 1) subtract two numbers, 2) compare two numbers and output the smaller, 3) test if a number is odd or even, or 4) quit the program. The program uses switch statements to evaluate the user's selection and call the corresponding operation code, then loops back to display the menu again until the user chooses to quit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<stdio.

h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,e;
clrscr();
do
{
read:
printf("\n\n\n------------Menu-----------\n");
/*Opening Menu*/
printf("1- for Subtract two integer\n");
printf("2- for Compare two Integer to find the Smallest\n");
printf("3- for Testing an Integer for Odd or Even\n");
printf("4- for Quit\n");
printf("\n------------Menu-----------\n\n\n");
printf("Enter your choice :");
/*User Choice Entry*/
scanf("%d",&e);
switch (e)
{
case 1:
/*Option 1: Subtract 2 integers*/
printf("Enter the Two Numbers :");
scanf("%d%d",&a,&b);
c=a-b;
printf("Subtraction of the two numbers is = %d",c);
break ;
case 2:
/*Option 2: Compare 2 integers*/
printf("Enter the Two Numbers :");
scanf("%d%d",&a,&b);
if(a>b)
printf("%d is smallest among the two integers.",b);
else
printf("%d is smallest among the two integers.",a);
break ;
case 3:
printf("Enter a Number :");
scanf("%d",&a);
if(a%2==0)
printf("The number is Even.");
else
printf("The number is Odd.");
break ;

/*Option 3: Test an integer*/

case 4:
break ;

/*Option 4: Exit*/

default :
printf("\nSorry!! Wrong Choice.\n");
goto read;
}
}
while (e!=0 && e!=4);
getch();
}

/*Re-Display Original Menu*/

You might also like