Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How to make a calculator in c programming?

+2 votes
asked Nov 24, 2020 by Superman365 (560 points)
edited Nov 25, 2020 by Admin

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

3 Answers

0 votes
answered Nov 24, 2020 by xDELLx (10,500 points)

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
answered Nov 24, 2020 by Satvik (140 points)

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
answered Nov 24, 2020 by dipanshu singh dhami (140 points)
#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;            
            
        }
        
        
        
        
    }
    
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...