create menu driven program to perform the following operation (a) addition(b) subtraction(c) multiplication (d)reminder (e)exit..
..
Answers
Answer:
#include<stdio.h>
// functions declaration
int add(int n1, int n2);
int subtract(int n1, int n2);
int multiply(int n1, int n2);
int divide(int n1, int n2);
// main function
int main()
{
int num1, num2;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
printf("%d + %d = %d\n", num1, num2, add(num1, num2));
printf("%d - %d = %d\n", num1, num2, subtract(num1, num2));
printf("%d * %d = %d\n", num1, num2, multiply(num1, num2));
printf("%d / %d = %d\n", num1, num2, divide(num1, num2));
return 0;
}
// function to add two integer numbers
int add(int n1, int n2)
{
int result;
result = n1 + n2;
return result;
}
// function to subtract two integer numbers
int subtract(int n1, int n2)
{
int result;
result = n1 - n2;
return result;
}
// function to multiply two integer numbers
int multiply(int n1, int n2)
{
int result;
result = n1 * n2;
return result;
}
// function to divide two integer numbers
int divide(int n1, int n2)
{
int result;
result = n1 / n2;
return result;
}
Badi mehnat se type kiya hai
Answer:
import java.util.Scanner;
public class calculator
{
public static void main(String args[])
{
double num1, num2, result=0;
Scanner a=new Scanner(system.in);
System.out.println("Calculator");
System.out.println("******************");
System.out.println("(A)ddition");
System.out.println("(S)ubstraction");
System.out.println("(M)ultiplication");
System.out.println("(D)ivison");
System.out.println("(E)xit");
System.out.println("°°°°°°°°°°°°°°°°°°°°°°°");
System.out.println("ENTER YOUR CHOICE(A, S, M, D, or E)");
char choice=a.next().charAt(0);
switch(choice)
{
case 'A' :
num1=AcceptInput(1);
num2=AcceptInput(2);
result=num1-num2;
break;
case 'S' :
num1=AcceptInput(1);
num2=AcceptInput(2);
result=num1-num2;
break;
case 'M' :
num1=AcceptInput(1);
num2=AcceptInput(2);
result=num1-num2;
break;
case 'D' :
num1=AcceptInput(1);
num2=AcceptInput(2);
result=num1-num2;
break;
case 'E' :
num1=AcceptInput(1);
num2=AcceptInput(2);
result=num1-num2;
break;
}
}