answersLogoWhite

0


Best Answer

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

int sum(int, int);

int sub(int, int);

int mul(int, int);

int div1(int, int);

int main() {

int a,b,d;

int ch;

printf("\t\tCalculator Implementation\n");

printf("\t\t~\n");

printf("\t\t 1: Add\n");

printf("\t\t 2: Sub\n");

printf("\t\t 3: Multiply\n");

printf("\t\t 4: Divide\n");

printf("\t\t 5: Exit\n\n\n");

printf("\t\t Enter the choice: ");

scanf("%d", &ch);

if(ch==5)

exit(0);

printf("\nEnter first number: ");

scanf("%d", &a);

printf("\nEnter Second number: ");

scanf("%d", &b);

printf("\na = %d; b = %d;\n", a, b);

printf("==============\n\n");

switch(ch)

{

case 1 :

d=sum(a,b);

printf("Sum %d + %d = %d",a,b,d);

break;

case 2:

d=sub(a,b);

printf("Subtraction %d - %d = %d",a,b,d);

break;

case 3:

d=mul(a,b);

printf("Multiplication %d * %d = %d",a,b,d);

break;

case 4 :

d=div1(a,b);

printf("Division %d / %d = %d",a,b,d);

break;

default:

printf("Invalid Choice!");

getch();

}

getch();

return 0;

}

int sum(int a, int b) {

return a + b;

}

int sub(int a, int b) {

return a - b;

}

int mul(int a, int b) {

return a * b;

}

int div1(int a, int b) {

return a / b;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Q5 Write a program to implement a calculator to perform all the four basic arithmetic operations on integers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the section of the CPU that performs arithmetic involving integers and logical operations?

The ALU (Arithmetic/Logic Unit)


What are the fundamental operations of integers?

I am not sure there are any fundamental operations of integers. The fundamental operations of arithmetic are addition, subtraction, multiplication and division. However, the set of integers is not closed with respect to division: that is, the division of one integer by another does not necessarily result in an integer.


Which are the possibe arithmetic operation with pointers?

Pointers in C are stored as integers. You can perform any mathematical operations on pointers that you can perform on ints.Of course not, the following operations are possible: =, +, +=, ++, -, -=, --, *, [], ->, typecast


Which operations on integers are commutative?

Addition and multiplication are operations on integers that are commutative.


What are the three basic categories of items that can be stored by memory?

Operating system and system software; application software; data being processed


What is an arithmetic function?

An arithmetic function is any function which is defined for all positive integers, and has values which are either real or complex.


What is integers and order of operations?

Part 2


What is Number and operations?

Numbers are an abstract concept developed from simple counting of objects. The basic set of counting numbers has been expanded so that they include the set of integers, other rational numbers, irrational numbers, complex numbers and quaternions. Operations are the rules for manipulating numbers. The basic operations of arithmetic are addition, subtraction, multiplication and division.


What are the average of all integers between 17 and 55?

The arithmetic mean is 36.


What are the Four kinds of fundamental operations in integers?

asa


What operations are closed for integers?

Addition, subtraction and multiplication.


4 basic operations of integers?

basic opration of inntegers