Originally Posted by
marcdaven
Code:
int add(int, int);
int subtract(int, int);
float divide(int, int);
int multiply(int, int);
sayop imong function prototypes above, it should match the function declarations nimo so the correct one should be
Code:
int add(int a, int b);
int subtract(int a, int b);
float divide(int a, int b);
int multiply(int a, int b);
Another thing
Originally Posted by
marcdaven
do not use scanf when dealing with characters and strings kay naa jud cya tendency mo skip sa input nga part, resulta wala madawat nga value ang nag hulat sa output gkan sa scanf(). Use the code below instead
HERE's THE COMPLETE WORKING CODE
Code:
#include<stdio.h>
#include<conio.h>
int add(int a, int b);
int subtract(int a, int b);
float divide(int a, int b);
int multiply(int a, int b);
void main(void)
{
int a, b, d, e, f;
float g;
char c;
clrscr();
printf("Enter two integers separated by a space:\n");
scanf("%d %d", &a, &b);
printf("Actions:\n(A) Add\n(S) Subtract\n(D) Divide\n(M) Multiply\n");
printf("Choice: ");
c=getche();
if (c=='A')
{
d=add(a, b);
printf("The sum of %d and %d is %d", a, b, d);
getch();
}
if (c=='S')
{
e=subtract(a, b);
printf("The difference of %d and %d is %d", a, b, e);
getch();
}
if (c=='D')
{
g=divide(a, b);
printf("The quotient of %d and %d is %f", a, b, g);
getch();
}
if (c=='M')
{
f=multiply(a, b);
printf("The product of %d and %d is %d", a, b, f);
getch();
}
getch();
}
int add(int a, int b)
{
return (a+b);
}
int subtract(int a, int b)
{
return (a-b);
}
int multiply(int a, int b)
{
return (a*b);
}
float divide(int a, int b)
{
return ((float)a/b);
}
GOOD LUCK