KEMBAR78
C Program: Basic Calculator | PDF
0% found this document useful (0 votes)
11 views1 page

C Program: Basic Calculator

Uploaded by

devaaanandanah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

C Program: Basic Calculator

Uploaded by

devaaanandanah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

//C program for simple calculator application

#include<stdio.h>

#include<stdlib.h>

int main()

int a,b,c,result;

char operator;

int result;

printf("Enter an expression to calculate:\n");

scanf("%d%c%d",&a,&operator,&b);

switch(operator){

case '+': result = a + b;

break;

case '-': result = a - b;

break;

case '*': result = a * b;

break;

case '/': result = a / b;

break;

case '%': result = a % b;

break;

default: printf("Enter a valid operator + - * / %");

exit(0);

printf("Result of expression %d %c %d = %d ", a,operator,b, result);

return 0;

You might also like