Code:
#include <stdio.h>
#include <stdlib.h>
void multiply();
void divide();
void add();
void substract();
int main()
{
int choise;
printf("Calculator.\n");
do
{
puts("MENU: \n");
puts("1 to multiply.");
puts("2 to divide.");
puts("3 to add.");
puts("4 to substract.");
puts("5 to exit.");
scanf(" %d", &choise);
switch (choise)
{
case(1) :
multiply();
break; //prevents other cases from executing
case(2) :
divide();
break;
case(3) :
add();
break;
case(4) :
substract();
break;
case(5) : exit(1);
break;
}
}
while((choise < 1) ||(choise > 5));
getchar();
getchar();
return 0;
}
void multiply()
{
float a, b, c;
puts("Enter numbers: ");
scanf(" %f", &a);
scanf(" %f", &b);
c = a * b;
printf("Answer: %f\n", c);
return;
}
void divide()
{
float a, b, c;
puts("Enter numbers: ");
scanf(" %f", &a);
scanf(" %f", &b);
c = a / b;
printf("Answer: %f\n", c);
return;
}
void add()
{
float a, b, c;
puts("Enter numbers: ");
scanf(" %f", &a);
scanf(" %f", &b);
c = a + b;
printf("Answer: %f\n", c);
return;
}
void substract()
{
float a, b, c;
puts("Enter numbers: ");
scanf(" %f", &a);
scanf(" %f", &b);
c = a - b;
printf("Answer: %f\n", c);
}
how do i add this "Do you want to run again y/n" thing into each of this? and what abt the key thing if u know hurry reply i gota go to play a game, totaly bored ;X
and also string operations