# 33+ C Language Calculator Examples

This post contains a total of 33+ Hand-Picked C language Calculators that are made purely using c language.

You can use the Source Codes of these C Calculators for educational use with credits to the original owner, in case you need it for some other use then contact the owner for permission.

### Related Posts

Click a Code to Copy it, and Hover over a video to play it.

## 1. By Nikhat Shah

Made by Nikhat Shah, you will need to first enter the symbol of what you want to do, like +, – or *. After that you will need to enter the first and second number to get the result. ( Source )

``````#include <stdio.h>
int main(){
char wish;
float num1,num2,result;
int flag =1;
printf(" Enter - , + , * ,/ for knowing result \n");
scanf("%c" , &wish);
printf ("Enter number 1\n");
scanf("%f", &num1 );
printf ("Enter number 2\n");
scanf("%f" , &num2 );

switch (wish)
{
case '+':
result =num1+num2;
break ;
case'-':
result =num1-num2;
break ;
case '/':
{
if (num2 ==0)
{
flag = 0;
}
else
{
result  =num1/num2;
}
break ;
}
case'*':
result = num1 *num2;
break ;
default : printf ("error");
break ;
}
if (flag ==1)
{
printf ("%f %c %f =%f" , num1, wish,num2 ,result );
}
else
{
printf ("%f %c %f = undefined" ,num1 ,wish ,num2 );
}
}``````

## 2. By Nicola Esu

Made by Nicola Esu, first enter the problem, like 2+2 then add ‘=’ at the end to get your result. For example – 2+3=. The program will only work if you add ‘=’ at the end. ( Source )

``````#include <stdio.h>
int main() {

int num1;
int tot = 0;
char b;

scanf("%d", &num1);

do {

scanf("%c", &b);
if ( b == '=') {
break;}
tot += num1;
num1 = 0;
scanf("%d", &num1);

switch (b) {

case '+':
tot = tot + num1;
num1 = 0;
break;

case '-':
tot = tot - num1;
num1 = 0;
break;

case '*':
tot = tot * num1;
num1 = 0;
break;

case '/':
tot = tot / num1;
num1 = 0;
break;

default:
printf("operation not allowed");
break;

}

}while ( b != '=');

printf("%d\n", tot);

return 0;
}``````

## 3. By Razeed Risham

A small c calculator program by Razeed Risham. You will need to just enter your operation and you will get the result. The program is limited to 4 arithmetic operations, ” +, -, *, / “. ( Source )

``````#include <stdio.h>
int main() {
char op;
float num1,num2;
printf ("\n Enter your operation here: ");
scanf("%f%c%f",&num1,&op,&num2);

switch (op)
{
case '+':
printf ("\nResult: %.2f",num1+num2);
break;
case '-':
printf ("\nResult: %.2f",num1-num2);
break;
case '*':
printf ("\nReslt: %.2f",num1*num2);
break;
case '/':
printf ("\nResult: %.2f",num1/num2);
break;
default:
printf("\n invalid inputs");
}

}``````

## 4. By Suraj Gupta

Made by Suraj Gupta. Enter your problem in one line, like ‘1+1’. ( Source )

``````#include <stdio.h>

int main() {
float x,y;
char operator;
printf ("enter a number\n");
printf ("enter an operator\n");
printf ("enter an another number\n");
scanf("%f %c %f",&x,&operator,&y);
if(operator =='+')
{
printf ("%f+%f=%f",x,y,x+y);
}
else if(operator =='-')
{
printf ("%f-%f=%f",x,y,x-y);
}
else if(operator =='*')
{
printf ("%f*%f=%f",x,y,x*y);
}
else if(operator =='/')
{
printf ("%f/%f=%f",x,y,x/y);
}
else
{
printf ("\ninvalid operator");
}
return 0;
}``````

## 5. By ✨SARANG✨

Made by ✨SARANG✨. Enter the operation in single line like ‘2+2’, The output will be shown and the operator you used will be printed like ‘You choose addition’. The program is limited to only two integers. ( Source )

``````#include <stdio.h>
int main()
{
char a;
int x,y,z,reminder;

scanf ("%d",&x);
scanf ("%c",&a);
scanf ("%d",&y);

switch (a)
{
case '+':
z=x+y;
break;

case '-':
printf ("You choose subtraction\n");
z=x-y;
break;

case '*':
printf ("You choose multiplication\n");
z=x*y;
break;

case '/':
printf ("You choose division\n");
z=x/y;
reminder=x%y;
printf ("The quotient is: %d\n",z);
printf ("The reminder is: %d",reminder);
break;

default:
printf ("Invalid input");
}
return 0;
}``````

## 6. By Ayushi Sharma

Made by Ayushi Sharma. You will need to enter the operator first then the numbers you want to multiply, add etc, like ‘ *2 2 ‘. Add a space between the numbers. ( Source )

``````#include<stdio.h>

int main()
{
int A,B;
char C;
scanf("%c",&C);
scanf("%d",&A);
scanf("%d",&B);
switch (C)
{
case '+':printf("%d",A+B);
break;
case '-':printf("%d",A-B);
break;
case '*':printf("%d",A*B);
break;
case '/':printf("%d",A/B);
break;
default :printf ("Wrong choice...")
;

}
return 0;
}``````

## 7. By Benjamin Ben

Made by Benjamin Ben. First enter the two number of the operation will space in middle, after that select the operator you want to use using 1,2,3,4. ( Source )

``````#include<stdio.h>
#include<math.h>
int main()
{
int a,b,numb;
//Entering the two numbers
printf("Enter the two numbers\n");
scanf("%d %d",&a,&b);

//Command
numb;
printf("Enter 1 for addition\n2 for subtraction\n3 for multiplication\n4 for division");
scanf("%d",&numb);

switch(numb)
{
case 2:printf("Subtraction:%d\n", a-b);break;
case 3:printf("Multiplication:%d\n",a*b);break;
case 4:printf("Division:%d\n",a/b);break;
default:printf("\nInvalid Command");

}
return 0;
}``````

## 8. By HonFu

Made by HonFu, enter the operation in one line like 2+2, don’t add any whitespace in between. You can also use Unary minus and decimals. ( Source )

``````#include <stdio.h>

double calc(double x, double y, char op) {
switch(op) {
case '+': return x+y;
case '-': return x-y;
case '*': return x*y;
case '/': return x/y;
}
return 0.0;
}

// This function extracts two operands and one
// operator from a string of the shape "1+2".
void tokenize(
double *x, double *y, char *op, char cl[]
) {
*x = 0;
*y = 0;
int i=0, dec=0, places=1;
double mult=1.0;

// Index set to end of string.
while(cl[i]) ++i;

// Backwards through string until we find
// a non-digit or non-'.' (so something that
// doesn't belong to the basic number y).
for(
--i;
(cl[i]>='0'&&cl[i]<='9')||cl[i]=='.';
--i
) {
// This sets a flag: float or not?
if(cl[i]=='.') {
dec = 1;
continue;
}

// Calculation of each digit
// into an actual number
*y += (cl[i]-48)*mult;
mult *= 10;

// until we find a '.'.
if(!dec) ++places;
}

// If this is a number with decimal places,
// we have to devide the number (which has been
// calculated as if there wasn't a '.')
// by 10 as often as we have places.
// (If this is no float, places will be all
// the digits, but it doesn't matter since we
// don't use the value places.)
if(dec) while(--places) *y /= 10;

// Index now either shows an operator or a unary
// minus. We test that by checking one digit
// further to the left to see if the next
// number starts there.
if(cl[i]=='-'&&(cl[i-1]<'0'||cl[i-1]>'9')) {
*y = -*y;
--i;
}

// Storing the operator now.
*op = cl[i];

// Now the whole procedure again
// for the left operand x.
dec = 0;
places = 1;
mult = 1.0;
for(--i; i>=0; --i) {
if(cl[i]=='.') {
dec = 1;
continue;
}
if(!i&&cl[i]=='-') {
*x = -*x;
break;
}
*x += (cl[i]-48)*mult;
mult *= 10;
if(!dec) ++places;
}
if(dec) while(--places) *x /=10;
}

int main() {
char calcline[10] = "-2*3.1", op;
double x, y;
scanf("%s", calcline);
tokenize(&x, &y, &op, calcline);
printf(
"%.2lf %c %.2lf = %.2lf\n\n\n"
"Prepared tests:\n\n",
x, op, y, calc(x, y, op)
);
char clines[7][18] = {
"54*-6.9",
"-6.78+23",
"576/-3.2",
"-1.1*-2.3",
"3*0.89",
"1.07+-2.06",
"5.70*-35.06"
};
for(int i=0; i<7; ++i) {
tokenize(&x, &y, &op, clines[i]);
printf(
"%.2lf %c %.2lf = %.2lf\n",
x, op, y, calc(x, y, op)
);
}
return 0;
}``````

## 9. By VSR [ DEV ]

Made by VSR [DEV]. You will need to first enter your first number after that enter the operator you want to use, after that enter the second number. ( Source )

``````#include <stdio.h>

int main() {
float num1, num2;
char op, ans, y, q;
while (1) {
printf("Enter First Number :");
scanf("%f", & num1);
printf("Enter operator :");
scanf(" %c", & op);
printf("Enter Second Number :");
scanf("%f", & num2);
switch (op) {
case '+':
printf("Sum of %f and %f is %f", num1, num2, num1 + num2);
break;
case '-':
printf("Subtraction of %f and %f is %f", num1, num2, num1 - num2);
break;
case '/':
printf("Division of %f and %f is %f", num1, num2, num1 / num2);
break;
case '*':
printf("Multiplication of %f and %f is %f", num1, num2, num1 * num2);
break;
default:
printf("Error10075:Entered wrong opertor");

}
break;
printf("If you want to recalculate press y :");
scanf(" %c", & ans);
if (ans == y) {
continue;
} else if (ans == q)
printf("You are exited");
else
printf("Entered wrong keyword");

}
return 0;
}``````

## 10. By Sufiyan Pathan

Made by Sufiyan. Enter the first number after which enter the operator, +,-,* etc., after which enter the second number to get the output. If you gave a invalid operator then it will give out a error. ( Source )

``````#include<stdio.h>
main()
{//clrscr();
float num1;
float num2;
char op;
float result;

printf ("enter the first number:");
scanf ("%f",&num1);

printf ("enter the operation:");
scanf  (" %c",&op);

printf ("enter the second number:");
scanf  ("%f",&num2);

switch (op)
{
case '-':
result = num1-num2;
printf ("%f",result);
break;

case '+':
result = num1+num2;
printf ("%f",result);
break;

case '*':
result = num1*num2;
printf ("%f",result);
break;

case '/':
result = num1/num2;
printf ("%f",result);
break;

default:
printf ("the operator is not valid:");
}
return 0;
}
``````

## 11. By Josna C. J

Made by Josna. You’ll need to first enter the operator after that enter the two numbers, the numbers need to have space in between them. ( Source )

``````#include <stdio.h>
int main()
{
int a,b;
char p;
printf("enter the process\n");
scanf("%c",&p);
printf("enter two numbers\n");
scanf("%d%d",&a,&b);
switch (p)
{
case'+':printf("%d",a+b);
break;
case'-':printf("%d",a-b);
break;
case'*':printf("%d",a*b);
break;
case'/':printf("%d",a/b);
break;
case'%':printf("%d",a%b);
break;
default:printf("wrong command");
break;
}
return 0;
}``````

## 12. By StarLord713

Made by StarLord713. First enter what amount of numbers you want to use in the process, like 2 ( 2 + 2 ) or 3 ( 2 + 2 + 2 ). After that enter the number you want to calculate with space between the numbers and operators. ( Source )

``````#include <stdio.h>
int main() {

int number;

printf("Enter the count of numbers that you will operate with.\n2 or 3\n");

scanf("%d",&number);

float a, b, c, d;

char x;
char y;

if(number==2)
scanf("%f %c %f",&a, &x, &b);

else if(number==3)
scanf("%f %c %f %c %f",&a, &x, &b, &y, &c);

else
printf("Syntax Error.\n");

if(number==2){
switch (x){

case '+':
d=a+b;
break;

case '-':
d=a-b;
break;

case '*':
d=a*b;
break;

case '/':
d=a/b;
break;

default :
printf("Syntax Error.\n");

}

}
else if(number==3){
switch (x){

case '+':
switch(y){

case '+':
d=a+b+c;
break;

case '-':
d=a+b-c;
break;

case '*':
d=a+b*c;
break;

case '/':

if(c==0)
printf("Math Error.\n");

else
d=a+b/c;
break;

}
break;

case '-':
switch(y){

case '+':
d=a-b+c;
break;

case '-':
d=a-b-c;
break;

case '*':
d=a-b*c;
break;

case '/':

if(c==0)
printf("Math Error.\n");

else
d=a-b/c;
break;

}
break;

case '*':
switch(y){

case '+':
d=a*b+c;
break;

case '-':
d=a*b-c;
break;

case '*':
d=a*b*c;
break;

case '/':

if(c==0)
printf("Math Error.\n");

else
d=a*b/c;
break;

}
break;

case '/':

if(b==0)
printf("Math Error.\n");

else
switch(y){

case '+':
d=a/b+c;
break;

case '-':
d=a/b-c;
break;

case '*':
d=a/b*c;
break;

case '/':

if(c==0)
printf("Math Error.\n");

else
d=a/b/c;
break;

}
break;

default:
printf("Syntax Error. \n");

}

}

return 0;
}``````

## 13. By BroFar C Calculator

Made by BroFar. First enter the operator you want to use then after that enter the operation with spaces between the numbers like ( 2 2 ), no need of adding operator in between. ( Source )

``````#include <stdio.h>
int main() {
char operator;
double fNum,sNum;
printf("Created by BroFarOps 11-15-2018\n");
printf("This is my 7th c language code\n");
printf("Enter an operator ( + - * / ): \n");
scanf("%c", &operator);
printf("Enter two numbers: \n");
scanf("%lf %lf",&fNum, &sNum);
switch(operator) {
case '+':
printf("%.1lf + %.1lf = %.1lf",fNum, sNum, fNum + sNum);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf",fNum, sNum, fNum - sNum);
break;
case '*': printf("%.1lf * %.1lf = %.1lf",fNum, sNum, fNum * sNum);
break;
case '/':
printf("%.1lf / %.1lf = %.1lf",fNum, sNum, fNum / sNum);
break;
default: printf("Error! operator is not correct");
printf("Error! operator is not correct");
printf("Please select + - * or /"); };
return 0; }``````

Made by Madhav. Enter the operation in one line like 1+1 without any spaces in between the numbers or the operators. Adding space will give errors. ( Source )

``````#include <stdio.h>
int main() {
int m,n,o;
char i;
scanf("%d",&m);
scanf("%c",&i);
scanf("%d",&n);
switch(i)
{
case '+':
o=m+n;
break;
case '-':
o=m-n;
break;
case '/':
o=m/n;
break;
case '*':
o=m*n;
break;
case '%':
o=m%n;
break;
default :
printf("\nOops !! Error Occured ");
break;
}
printf("\n%d",o);
return 0;
}``````

## 15. By Bhatesh Khairnar

Made by Bhatesh Khairnar. You’ll need to first enter the first number, after that enter the operator you want to use after that enter the second number, this will give you the output. ( Source )

``````#include <stdio.h>
#include <conio.h>
main() {
char
operator;
clrscr();
float result;
float num1 ;
float num2 ;
printf("Enter the first number:");
scanf("%f",&num1);
printf("Enter an  operation:");
scanf("%c",&operation);
printf("Enter the second number:");
scanf("%f",&num2);
switch (operation )
{
case '-':
result = num1-num2;
printf  ("%f",result);
break ;

case'+':
result  = num1+num2;
printf("%f",result);
break ;

case'*':
result = num1 *num2;
printf("%f",result);
break ;

case'/':
result = num1 /num2;
printf("%f",result );
break;

default :
printf("the operation is not valid:");
}
getch();
return 0;
}``````

## 16. By Ankit Kumar

Made by Ankit Kumar. Enter the operation in the the format ‘1 1+’, add first number then space then add second number then add the operator you want to use without space. ( Source )

``````#include <stdio.h>

int add (int , int );
int subtract (int , int );
int mult (int , int );
int divide (int , int );
int main ()
{
char x='+';int a,b,y=0;
printf ("Enter two no.(s) to operate\n");
scanf ("%d%d",&a,&b);
printf ("What function you want\nadd: +\nsubtract: -\nmultiply: *\ndivide: /\n");
scanf("%c",&x);
switch (x){
case '+':
case '-':
y=subtract(a,b);break;
case '*':
y=mult (a,b);break;
case '/':
y=divide (a,b);break;
}
printf("Result= %d",y);
return 0;
}
int add (int first, int second){

first += second;
return first;
}
int subtract (int a1, int a2){
a1 -= a2;
return a1;
}
int mult (int q, int w){
q *= w;
return q;
}
int divide (int q, int w){
q /= w;
return q;
}
/* Enter values like " 34 23+ "
result will be " 57 " */``````

## 17. By Junior Rido

Small c calculator program that is small in size but is very good in functionality. All you need to enter is first and second number and the program will print out all the results of different operators, like addition, multiplication, etc. No need to select operator manually. ( Source )

``````#include<stdio.h>
int main()
{
int a;
int b;
printf ("Enter fist number 'a' \n");
scanf ("%d", &a);
printf ("Enter the second value 'b' \n");
scanf ("%d", &b);
int c = a + b;
int d = a - b;
int e = a * b;
int f = a / b;
printf ("The sum of a and b is %d \n", c);
printf ("The subtraction of a and b is %d \n", d) ;
printf ("The multiplication of a and b is %d \n", e);
printf ("The divide of a and b is %d \n", f);
return 0;
}``````

## 18. By Priya Kumari

Made by Priya Kumari. First enter the two numbers that you want, enter first number then give a space and enter the second number, after that select the operator that you want to use by entering its number. You’ll get the result after you select the operator. ( Source )

``````#include <stdio.h>

void main()
{
int a,b,num;

scanf("%d%d",&a,&b);
printf("enter numbers:%d %d\n",a,b);

printf("Choose an option:\n");
printf("1.Sum\n2.Subtract\n3.Multiply\n4.Divide\n5.Modulus\n");
scanf("%d",&num);
switch (num)
{
case(1):
{
printf("sum=%d",a+b);
break;
}
case(2):
{
printf("subtract=%d",a-b);
break;
}
case(3):
{
printf("multiply=%d",a*b);
break;
}
case(4):
{
printf("divide=%d",a/b);
break;
}
case(5):
{
printf("modulus =%d",a%b);
break;
}
default:
printf ("\n \n syntax error");

}

}``````

## 19. By Ahmed Hesham

Made by Ahmed Hesham. You’ll need to enter the whole operation in one single line, you can add space in between the numbers and operators or you can run it without any space, like ‘1+1’ or ‘1 + 1’. ( Source )

``````#include <stdio.h>

int main() {
float num1,num2;
char op;

scanf("%f %c %f", &num1, &op, &num2);

switch(op)
{
case '+':
printf("%0.2f + %0.2f = %0.2f", num1, num2, num1 + num2);
break;
case '-':
printf("%0.2f - %0.2f = %0.2f", num1, num2, num1 - num2);
break;
case '*':
printf("%0.2f * %0.2f = %0.2f", num1, num2, num1 * num2);
break;
case '/':
if(num2 == 0)
{
printf("Error we can't divide by zero");
break;
}
else
{
printf("%0.2f / %0.2f = %0.2f", num1, num2, num1 / num2);
}
break;
default:
printf("sorry the calculator is designed to do limited operation(+, -, *, /)");
}

return 0;
}``````

## 20. By Pratik Kante

Made by Pratik Kante. First you will need to select the operator that you want to use, you can do that by entering the operator number, after that you will need to enter the two numbers with space in between them like – 7 8. ( Source )

``````#include <stdio.h>

int main() {
int ch,num1,num2;
printf("2.Substraction\n");
printf("3.Multiplication\n");
printf("4.Division\n");
printf("5.Exit\n");

scanf("%d",&ch);

switch(ch){

case 1: printf("Enter two numbers\n");
scanf("%d%d",&num1,&num2);
printf("Sum is %d",num1+num2);
break;

case 2: printf("Enter two numbers\n");
scanf("%d%d",&num1,&num2);
printf("Subtraction is %d",num1-num2);
break;

case 3: printf("Enter two numbers\n");
scanf("%d%d",&num1,&num2);
printf("Product is %d",num1*num2);
break;

case 4: printf("Enter two numbers\n");
scanf("%d%d",&num1,&num2);
printf("Quotient is %d",num1/num2);
break;

default: printf("Envalid choice");

}

return 0;
}``````

## 21. By Lakshay kamat

Made by Lakshay kamat. Enter your operation in one single line without any space in between the number and operator like ( 2+2 ). ( Source )

``````#include <stdio.h>
int main(int argc, char const *argv[])
{

/*
Enter any two Number and add Opeartion between you can use
thi +, -, *, /

ex-  5+5
ex - 23*2 */
double num1,num2;
char Opeartion;
scanf("%lf%c%lf",&num1,&Opeartion,&num2);
printf("You Entered = %.1lf %c %.1lf\n\n",num1,Opeartion,num2);

switch (Opeartion)
{
case '+':
break;
case '/':
break;
case '*':
break;
case '-':
break;

default:
break;
}
return 0;
}``````

## 22. By Swapnil

Simple C Calculator by Swapnil that can also do modulus calculations. Enter the operation in single liner without spaces. Like for example 3+3, 3%3. ( Source )

``````#include <stdio.h>

int main() {
int a,b,c;
float e,f;
char x,d='%';
printf("Enter 1st number: ");
scanf("%d",&a);
printf("%d\n",a);
printf("Enter the operator: ");
scanf("%c",&x);
printf("%c\n",x);
printf("Enter 2nd number: ");
scanf("%d",&b);
printf("%d\n",b);
switch(x){
case '+':
c=a+b;
printf("%d + %d = %d",a,b,c);
break;
case '-':
c=a-b;
printf("%d - %d = %d",a,b,c);
break;
case '*':
c=a*b;
printf("%d * %d = %d",a,b,c);
break;
case '/':
f=b;
e=a/f;
printf("%d / %d = %f",a,b,e);
break;
case '%':
c=a%b;
printf("%d %c %d = %d",a,d,b,c);
break;
default:
printf("Invalid Operator\nThe following operations that are: \n+ For Addition\n- For Subtraction\n* For Multiplication\n/ For Division\n%c For Dividing two numbers and printing its remainder",d);
}

return 0;
}``````

## 23. By Rushikesh Patil

Made by Rushikesh Patil. Enter the operation with first number then operator that you want to use then the second number, add spaces between numbers and operator like ( 7 + 7 ). ( Source )

``````#include <stdio.h>
int main(){
double n1, n2;
char op;
scanf("%lf %c %lf ", &n1, &op, &n2);

switch(op){
case '+':
printf("%.2lf %c %.2lf = %.2lf", n1, op, n2, n1 + n2);
break;
case '-':
printf("%.2lf %c %.2lf = %.2lf", n1, op, n2, n1 - n2);
break;
case '*':
printf("%.2lf %c %.2lf = %.2lf", n1, op, n2, n1 * n2);
break;
case '/':
printf("%.2lf %c %.2lf = %.2lf", n1, op, n2, n1 / n2);
break;
default:
printf("Error: Wrong operator chosen!! \n");
printf("you entered: %.2lf %c %.2lf \n", n1, op, n2);
printf("select between +, -, *, /");
};

return 0;
} ``````

## 24. By Tawhidul Islam Fahim

Made by Tawhidul Islam Fahim. You’ll need to enter first number then the operator then after that the second number to get the output. ( Source )

``````#include <stdio.h>
int main(){
double fn, sn, result;
char op;
//fn for first Number
//sn for second number
//op for operation
printf("Enter the first Number.\n");
scanf("%lf", &fn);
scanf(" %c", &op);
//please provide a space in scanf before &c
printf("Enter the second Number.\n");
scanf("%lf", &sn);
if(op=='+'||op=='-'||op=='*'||op=='/'){
if(op=='+')
result=fn+sn;
else if(op=='-')
result=fn-sn;
else if(op=='*')
result=fn*sn;
else if(op=='/')
result=fn/sn;
printf("\n%.2lf %c %.2lf =\t %.2lf", fn,op,sn,result);}
else printf("\n ERROR!!! This operation is not supported. Use +,-,*,/ as operand");
//You can avoid these.These are ending statement.

printf("\n\nIf you like it, Please hit a upvote!!!\n");
printf("______________________________________\n");
printf("Thanks for all the people! I have made this for you. Love you all.");
}``````

## 25. By Rahul Deshmukh

Made by Rahul Deshmukh. You’ll need to enter the whole operation in single line, you can enter the operation with and without spaces like (1+1) or (1 + 1). The output will print what operator you used and the answer. ( Source )

``````#include <stdio.h>

int main() {
double num1 ;
double num2 ;
char operator ;

/*printf ("Enter 1st number: \n");*/
scanf("%lf", &num1);
/*printf ("Enter operator: \n");*/
scanf(" %c", &operator);
/*printf ("Enter 2nd number: \n");*/
scanf("%lf", &num2);

printf ("1st number: %f\n", num1);
printf ("Operator : %c\n" , operator);
printf ("2nd number: %f\n", num2);

if( operator == '+'){
} else if (operator == '-'){
} else if (operator == '*'){
} else if (operator == '/'){
} else {
printf("Wrong operator");
}

return 0;
} ``````

## 26. By Smarty Penguin

Made by Smarty Penguin. Enter two number with space in between to get their addition, subtraction, division etc. ( Source )

```2 2
Result :
4
4
1
0```
``````#include <stdio.h>

int main() {
int e, b;
scanf("%d %d",&e, &b);
printf("Result : %d \n %d \n %d \n %d",e+b,e*b,e/b,e-b);
return 0;
}``````

## 27. By Ahmed Mahmoud

Made by Ahmed Mahmoud. ( Source )

```2+2
the result of 2.00 + 2.00 = 4.00```
``````#include <stdio.h>

int main()
{
float x,y,z ;
char op ;
scanf("%f%c%f",&x,&op,&y);
switch(op)
{
case'+':
z=x+y ;
break;
case'*':
z=x*y ;
break ;
case'-':
z=x-y ;
break ;
case'/':
z=x/y;
break;
default :
printf("unknown operator");
}
printf("\n the result of %.2f %c %.2f = %.2f",x,op,y,z);
return 0;
}``````

## 28. By Yash

Made by Yash. Put two values for operation. ( Source )

``` dial two number
___________________
|first value = 2 |
|second value  = 2|
_____________________
|0 subtraction     |
|1  division        |
|4 multiplication  |_```
``````#include <stdio.h>
#include <stdlib.h>
int main()

{
int a,b,c,d,f,g;
printf(" dial two number\n");
scanf("%d %d",&a,&b);
if(a>0&&b>0){
printf("___________________\n|first value = %d |\n|second value  = %d|\n_____________________\n",a,b);
if(a>=b)
{
c=a+b;
d=a-b;
f=a/b;
g=a*b;
printf("|%d subtraction     |\n",d);
printf("|%d  division        |\n",f);
printf("|%d multiplication  |",g);
printf("_____________________\n");
puts("\n*if you like or  any"
"\nthanks friends for great"
" support*");
}
else if(b>a){
c=a+b;
d=b-a;
f=a/b;
g=a*b;
printf("|%d subtraction     |\n",d);
printf("|%d  division        |\n",f);
printf("|%d multiplication  |\n",g);
printf("_____________________\n");
puts("\n*if you like or  any"
"thanks friends for great"
" support");
}
}
else{
printf("not entered input");
}

}

``````

## 29. By SWETA X

Made by SWETA X. ( Source )

```2 3
2 + 3 = 5
2 - 3 = -1
2 * 3 = 6
2 / 3 = 0
2 % 3 = 2```
``````#include <stdio.h>

int sum(int x,int y);
int diff(int x,int y);
int mul(int x,int y);
int div(int x,int y);
int mod(int x,int y);
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d + %d = %d\n",a,b,sum(a,b));
printf("%d - %d = %d\n",a,b,diff(a,b));
printf("%d * %d = %d\n",a,b,mul(a,b));
printf("%d / %d = %d\n",a,b,div(a,b));
printf("%d %% %d = %d\n",a,b,mod(a,b));
return 0;
}

int sum(int x,int y){
int z;
z=x+y;
return(z);
}

int diff(int x,int y){
int z;
z=x-y;
return(z);
}

int mul(int x,int y){
int z;
z=x*y;
return(z);
}

int div(int x,int y){
int z;
z=x/y;
return(z);
}

int mod(int x,int y){
int z;
z=x%y;
return(z);
}``````

## 30. By AsterisK

Made by AsterisK. Enter your calculation in this format 4 – 2, 6 + 8. ( Source )

`enter your desired number for calculation with the arithmetic signs:  4 - 2 = 2.000000`
``````#include <stdio.h>
int main(){
char operator = 0;
double number1 = 0.0;
double number2 = 0.0;

printf("\nenter your desired number for calculation with the arithmetic signs: ");
scanf("%lf %c %lf", &number1, &operator, &number2);

switch(operator){
case '+':
printf(" = %lf\n", number1 + number2);
break;

case '-':
printf(" = %lf\n", number1 - number2);
break;

case '*':
printf(" = %lf\n", number1 * number2);
break;

case '/':
if(number2 == 0)
else
printf(" = %ld\n", (long)number1 / (long)number2);
break;

case '%':
if((long)number2 == 0)
else
printf(" = %ld\n", (long)number1 % (long)number2);
break;

default:
printf("\n\n\aillegal operation!\n");
break;
}

return 0;
}
``````

## 31. By Vikas Tiwari

Made by Vikas Tiwari. Enter expression in following format : 12 + 5. ( Source )

```Enter Your expression: 12+2
For ex. 12*4
12+2=14```
``````#include <stdio.h>
int main() {
long num1,num2,result=0;
char operator;
printf ("Enter Your expression:\nFor ex. 12*4\n");
scanf("%ld%c%ld",&num1,&operator,&num2);
switch(operator )
{
case'+':
result =num1+num2;
printf ("%ld+%ld=%ld",num1,num2,result  );
break ;
case '-':
result =num1-num2;
printf ("%ld-%ld=%ld",num1,num2,result );
break ;
case '*':
result =num1*num2;
printf ("%ld*%ld=%ld",num1,num2,result );
break ;
case '/':
result =num1/num2;
printf ("%ld/%ld=%ld",num1,num2,result );
break ;
default :
printf ("Invalid operator entered" );
}
return 0;
}``````

## 32. By BelugaCat

Made by BelugaCat. ( Source )

```3 3 +
``````#include <stdio.h>

int main() {
int a, b, c;
char ch;
scanf("%d %d %c", &a, &b, &ch);
switch(ch){
case '+': c= a+b;
break;
case '-': c= a-b;
break;
case '*': c= a*b;
break;
case '/': c= a/b;
break;
case '%': c=a%b;
break;
}
return 0;
}``````

## 33. By Ritik Gautam

Made by Ritik Gautam. ( Source )

```1+1
``````#include <stdio.h>

int main() {
int a,b,c;
scanf ("%i", &a);
scanf("%i", &b);
scanf("%i",&c);

if("c==+")

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

else if("c==-")

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

return 0;
}``````

## 34. By Mohammad Amir Aqeel

Made by Mohammad Amir Aqeel. Basic Calculator (using if else statement and do while loop). ( Source )

```ENTER THE OPERATOR TO BE PERFORMED (+,-,*,/,) : +
ENTER TWO NUMBERS : 5 5
RESULT : 10.00

PRESS 1 TO CONTINUE ```
``````#include <stdio.h>
#include <stdlib.h>

int main()
{
int d;
float a,b,c;
char e;
do
{printf("ENTER THE OPERATOR TO BE PERFORMED (+,-,*,/,) : ");
scanf("%c",&e);
start:
printf("ENTER TWO NUMBERS : ");
scanf("%f%f",&a,&b);
if(e=='/'&&b==0)
{
printf("SECOND NUMBER CANNOT BE ZERO !!!!");
goto start;
}
if(e=='+')
c=a+b;
else if(e=='-')
c=a-b;
else if(e=='*')
c=a*b;
else if(e=='/')
c=a/b;
printf("RESULT : %.2f",c);
printf("\n\n\n PRESS 1 TO CONTINUE ");
scanf("%d",&d);
}while(d==1);
return 0;
}
``````