c calculator program

Solutions on MaxInterview for c calculator program by the best coders in the world

showing results for - "c calculator program"
Julia
11 Jan 2020
1#include <stdio.h>
2int main() {
3    char operator;
4    double first, second;
5    printf("Enter an operator (+, -, *,): ");
6    scanf("%c", &operator);
7    printf("Enter two operands: ");
8    scanf("%lf %lf", &first, &second);
9
10    switch (operator) {
11    case '+':
12        printf("%.1lf + %.1lf = %.1lf", first, second, first + second);
13        break;
14    case '-':
15        printf("%.1lf - %.1lf = %.1lf", first, second, first - second);
16        break;
17    case '*':
18        printf("%.1lf * %.1lf = %.1lf", first, second, first * second);
19        break;
20    case '/':
21        printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
22        break;
23        // operator doesn't match any case constant
24    default:
25        printf("Error! operator is not correct");
26    }
27
28    return 0;
29}
Luis
31 Jan 2017
1#include <stdio.h>
2//Simple Calculator
3int main() {
4
5        int fno;
6        int sno;
7        int rst;
8       char opr;
9       printf ( "Enter First Number: ");
10       scanf("%d", &fno);
11       printf ("Enter Second Number: ");
12       scanf("%d", &sno);
13       printf ("Type Operator : ");
14       scanf(" %c", &opr);
15       rst = fno + sno;
16    if (opr == '+')
17    
18        printf ("%d \n", fno+sno);
19    
20      else (opr == '-');
21        printf ("%d \n", fno-sno);
22
23    if (opr == '*')
24    
25        printf("%d \n", fno*sno);
26
27      else (opr == '/');
28        printf ("%d \n", fno/sno);
29}
30
31
Gauthier
31 Jun 2016
1/*C program to design calculator with basic operations using switch.*/
2 
3#include <stdio.h>
4 
5int main()
6{
7    int num1,num2;
8    float result;
9    char ch;    //to store operator choice
10     
11    printf("Enter first number: ");
12    scanf("%d",&num1);
13    printf("Enter second number: ");
14    scanf("%d",&num2);
15     
16    printf("Choose operation to perform (+,-,*,/,%): ");
17    scanf(" %c",&ch);
18     
19    result=0;
20    switch(ch)    
21    {
22        case '+':
23            result=num1+num2;
24            break;
25             
26        case '-':
27            result=num1-num2;
28            break;
29         
30        case '*':
31            result=num1*num2;
32            break;
33             
34        case '/':
35            result=(float)num1/(float)num2;
36            break;
37             
38        case '%':
39            result=num1%num2;
40            break;
41        default:
42            printf("Invalid operation.\n");
43    }
44 
45    printf("Result: %d %c %d = %f\n",num1,ch,num2,result);
46    return 0;
47}
queries leading to this page
c language calculator codesimple calculator using cc how to make calculatorc program calculation using functionscalculator code ccalculator c meaningc code calculatorwrite a simple calculator program in cc 23 calculatorcalculator syntax for ccalculator c code sourceswitch case in c to add subtract two numberssimple calculator cwrite a program in c to calculaterhow to use the calculator function in cc calculator codecreate calculator in cc calculator programsimple calculator in chow to make a calcualtor in cbasic calculator program in c using functionshow to create a calculator in cc calculator onlinecalculator cghow to make a simple calculator on ccalculator syntax csimple calculator program in ccreate calc with cwhat is c in calculatorwhat does c mean in a calculatorc program to make a calculatorwhat is in 25 in programming calculation c calculatorwrite a simple calculator using if else statement that prompts the user to input two numbers then it will display the menu for addition 2c subtraction 2c multiplication 2c division 2c square of 1st number 2c cube of 1st after any choice it will display the answerhow to make a calculator using cwhere to find c in calculatorhow to use c in calculatorhow to make calculator in ccode for calculator in chow to make calculator in c on basiccalculator switch statementchange calculator in cc calculatorcalculator basic program in cc prgorma calculatorsimple calculation in c languagecalculation coding in cc simple calculatorc basic calculatorcalculator c programc programming langugage calculatorc make calculatorcalculatrice ccalculator c programmingc program calculatorbuilding calculator cc program for calulatorc program to make all betwice operationscalculator sine c codecalculator c codecalculator with c languagehow to implement 3d in a calculator in ccalculator in ccalculator csimple calculatopr in cpwrite a program of calcultor in c languagesimple calculator program in c using functionscalculator program in chow to create calculator in ccalculator code in ccalc c compilerwrite a calculator in cc code solvercalculator using function in cbuild a calculator cc calculatorhow to calculate in ccalcullator in cbasic calculator using switch case in ccalculator c and cemake calculator with cbuild a simple calculator using chow to create a basic calculator in cbasic calculator code cbasic calculator program in cc language buave calculatorcalculator c languagebasic calculation program in cc sample codes for calculatorcalculator using switch case in cbasic c calculator programcalculator with ckalkylator c programmingcode of calculator in ccalc c compiler 27create a simple calculator using c programbasic calculator in cof calculation in cconverting calculation in c programmingcalculator on c languagewriting calculator in c languagec calculadoraa simple calculator in cmake calculator in c to find add 2csub and powersimple calculator in c programcalculatore c program in cc program for simple calculatorcreate a calculator using switch case in csimple c calculator programcalculator using cwrite an c program that is calculatorc 27 calculatec programming solverc calculator with switchcreate a calculator in ccalculator in c languagec program for calculatorc program calculator using functionsc language calculatorc program for a calculatormaking calculator in ccalculator program in c using functionshow to make a calcaulator in ccalculatrice in cclass c subnet calculatorcalculator function in ca c program to make a calculatorbasic calculator c programc code for calculatorcreate a simple calculator in c programming presenting option for 4 diffrent cahow to run make an calculatorbasic c calculator program in cc program simple calculatorc calculatricecalculator in c using functionscalculator with c 28 29how to make a calculator in cc calculate with 25how to make calculator in c languagec clculatorc meaning calculatoronline c calculatorc calculator program