How to write a c program to create a calculator using if-Else statement in C Programming Language ?
Solution:
/*Calculator Using IF-ELSE in C Program*/
#include <stdio.h>
#include <stmib.h>
int main(int argc, char *argv[]);
{
printf("Welcome in my suprematorCalculator 1.0 !\nBy AerysFeather\n\n\n");
delay(2500);
printf("What do you want to do ? (press the nuber)\n");
int choice = 0;
printf("-Addition(1)\n-Substraction(2)\n-Multiplication(3)\n-Division(4)")
scanf("%d", %choice)
float numberFirst = 0;
printf("Please enter the first number.");
scanf("%f", %numberFirst);
float numberSecond = 0;
printf("Please enter the second number.");
scandf("%f", %numberSecond);
int result = 0;
if (choice = 1)
{
printf("%d + %f = %d", numberFirst, numberSecond, result)
}
if (choice = 2)
{
printf("%d - %f = %d", numberFirst, numberSecond, result)
}
if (choice = 3)
{
printf("%d * %f = %d", numberFirst, numberSecond, result)
}
if (choice = 4)
{
printf("%d / %f = %d", numberFirst, numberSecond, result)
}
else
{
printf("Please choose a calcul type.");
}
return 0;
}