**How to make a calculator in c programming? Is it possible? Could it calculate in addition, division, subtraction and multiplication?**********

0 votes

**How to make a calculator in c programming?**

You will have to learn to write code in C language & check for compile errors & then check by inputting numbers to make sure its working right.

**Is it possible? Could it calculate in addition, division,subtraction and multiplication?**

Limiting yourself to just add,subtract,division ,multiplication wont help you grow much,you can try to perform more complex operations like vector calculation,geometric,matrix operations etc, provided you understand these concepts

commented
Nov 24, 2020
by
dipanshu singh dhami
(140 points)

yes ,It can be possible by using switch case and array

0 votes

**Yes, it is possible!!**

**Program**

#include <stdio.h>

#include<conio.h>

int main()

{

int num1, num2;

int sum, sub, mult, mod;

float div;

printf("Input any two numbers separated by comma : ");

scanf("%d,%d", &num1, &num2);

sum = num1 + num2;

sub = num1 - num2;

mult = num1 * num2;

div = (float)num1 / num2;

mod = num1 % num2;

printf("The sum of the given numbers : %d\n", sum);

printf("The difference of the given numbers : %d\n", sub);

printf("The product of the given numbers : %d\n", mult);

printf("The quotient of the given numbers : %f\n", div);

printf("MODULUS = %d\n", mod);

return 0;

}

0 votes

#include<stdio.h>

#include<conio.h>

int main()

{

int num1,num2,option;

printf("Enter the first integer:");

scanf("%d",&num1);

printf("Enter the second integer:");

scanf("%d",&num2);

for(; ;)

{

printf("Enter your option:");

printf("1-Addition,2-Subtraction,3-Division,4-Multiplication,5-Exit");

scanf("%d",&option);

switch (option)

{

case 1: printf("Addition of %d and %d is :%d",num1,num2,num1+num2);

break;

case 2: printf("Subtraction of %d and %d is :%d",num1,num2,num1-num2);

break;

case 3: printf("Division of %d and %d is :%d",num1,num2,num1*num2);

break;

case 4:

if (num2==0)

{

printf("OOp divide by zero");

}

else

{

printf("Multiplication of %d and %d is :%d",num1,num2,num1/num2);

}

break;

case5:return 0;

break;

default:printf("Enter Correct option:");

break;

}

}

}

#include<conio.h>

int main()

{

int num1,num2,option;

printf("Enter the first integer:");

scanf("%d",&num1);

printf("Enter the second integer:");

scanf("%d",&num2);

for(; ;)

{

printf("Enter your option:");

printf("1-Addition,2-Subtraction,3-Division,4-Multiplication,5-Exit");

scanf("%d",&option);

switch (option)

{

case 1: printf("Addition of %d and %d is :%d",num1,num2,num1+num2);

break;

case 2: printf("Subtraction of %d and %d is :%d",num1,num2,num1-num2);

break;

case 3: printf("Division of %d and %d is :%d",num1,num2,num1*num2);

break;

case 4:

if (num2==0)

{

printf("OOp divide by zero");

}

else

{

printf("Multiplication of %d and %d is :%d",num1,num2,num1/num2);

}

break;

case5:return 0;

break;

default:printf("Enter Correct option:");

break;

}

}

}

...