Calculator

Here is calculator:

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
int a,b,c,g;
long double d,e;

printf("Chose Yourself\n1. Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Factorial\n6.Square\n7.Square root\n");
scanf("%d",&a);
if(a==1)
{
    printf("Give two numbers\n");
    scanf("%d%d",&b,&c);
    g=b+c;
    printf("Your answer is %d",g);
}
if(a==2)
{
    printf("Give two numbers\n");
    scanf("%d%d",&b,&c);
    g=b-c;
    printf("Your answer is %d",g);
}
if(a==3)
{
    printf("Give two numbers\n");
    scanf("%d%d",&b,&c);
    g=b*c;
    printf("Your answer is %d",g);
}
if(a==4)
{
    printf("Give two numbers\n");
    scanf("%d%d",&b,&c);
    g=b/c;
    printf("Your answer is %d",g);
}
if(a==5)
{
    printf("Give a number\n");
    scanf("%d",&b);
    while(b!=0)
    {
        d=d*b;
        b--;
    }
    printf("Your answer is %Lf",d);
}
if(a==6)
{
    printf("Give a number\n");
    scanf("%d",&b);
    e=b*b;
    printf("Your answer is %Lf",e);
}
if(a==7)
{
    printf("Give a number\n");
    scanf("%d",&b);
    g=pow(b,0.5);
    printf("Your answer is %d",g);
}
return 0;

}

Happy coding!

2 Likes

He tanks thats a nice calculator

1 Like

make some gui based calculator…hav fun…nice:)D

2 Likes

yeah try making GUI program of it.

1 Like

hi thats a nice calculator
Try to make computer calculator

1 Like

Add more operators like-- and, or, shift operators and many more. (Specially a calculator for programmers-- I mean use operators that are frequently used by us during programming).

Any how its a nice effort.

Happy Coding!!

1 Like

can any one help me to get the calculator code in java script

hey but i dont know java i can give you code in c, c++, pascal

because they are easy to understand

//