Hi SF,
I made a little calculator, like Xenocide but in C and I made it like 3 weeks ago but here it is:
I made a little calculator, like Xenocide but in C and I made it like 3 weeks ago but here it is:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int equation, nombre1, nombre2, resultat, calculator=1;
printf("Calculator in C by So.Liberty\n\n");
while(calculator){
printf("Which operation would you like to do?\n\n");
printf("1. Addition\n");
printf("2. Substraction\n");
printf("3. Multiplication\n");
printf("4. Division\n");
scanf("%d", &equation);
if(equation ==1)
{
printf("\n\nAddition\n\n");
printf("Enter the first number:\n");
scanf("%d", &nombre1);
printf("Enter the second one:\n");
scanf("%d", &nombre2);
resultat=nombre1+nombre2;
printf("There you go: %d", resultat);
printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
scanf("%d",&calculator);
}
else if(equation==2)
{
printf("\n\nSubstraction\n\n");
printf("Enter the first number:\n");
scanf("%d", &nombre1);
printf("Enter the second one:\n");
scanf("%d", &nombre2);
resultat=nombre1-nombre2;
printf("There you go: %d", resultat);
printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
scanf("%d",&calculator);
}
else if(equation==3)
{
printf("\n\nMultiplication\n\n");
printf("Enter the first number:\n");
scanf("%d", &nombre1);
printf("Enter the second one :\n");
scanf("%d", &nombre2);
resultat=nombre1*nombre2;
printf("There you go: %d", resultat);
printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
scanf("%d",&calculator);
}
else if(equation==4)
{
printf("\n\nDivision\n\n");
printf("Enter the first number:\n");
scanf("%d", &nombre1);
printf("Enter the second one:\n");
scanf("%d", &nombre2);
resultat=nombre1/nombre2;
printf("There you go: %d", resultat);
printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
scanf("%d",&calculator);
}
else
{
printf("Go away if you don't like mathematics");
}}
return 0;
}