//Calculator written in C
//Coded by dBx @ h4ckinab0x
#include <stdio.h>
#include <conio.h>
int main()
{
printf("On Your Marks. Get Set. Calculate!\n\n");
printf("Press [1] for Addition\n");
printf("Press [2] for Subtraction\n");
printf("Press [3] for Multiplication\n");
printf("Press [4] for Division\n");
getch();
if("choice==1")
{
int num1;
int num2;
int sum;
printf("Enter Your Number:\n");
scanf("%d", &num1);
scanf("%d", &num2);
sum = num1 + num2;
printf("The Answer is %d!", sum);
}
else if("choice==2")
{
int num1;
int num2;
int sub;
printf("Enter Your Number:\n");
scanf("%d", &num1);
scanf("%d", &num2);
sub = num1 - num2;
printf("The Answer is %d!", sub);
}
else if("choice==3")
{
int num1;
int num2;
int multi;
printf("Enter Your Number:\n");
scanf("%d", &num1);
scanf("%d", &num2);
multi = num1 * num2;
printf("The Answer is %d!", multi);
}
else if("choice==4")
{
int num1;
int num2;
int dvs;
printf("Enter Your Number:\n");
scanf("%d", &num1);
scanf("%d", &num2);
dvs = num1 / num2;
printf("The Answer is %d!", dvs); }
getch();
}
What am i doing wrong...when i compile it,
the exe shows up. but the functions dont work.
i think i have to set them as for example;
sub = subtraction;
etc.
also i think i should use switch/case statements.
or do while loops..
but im having trouble with it ]:


Sign In
Create Account

Back to top










