I have the following code:
Code:
#include <stdio.h>
#include <stdlib.h>
int multiply(long x, long y);
int divide(long x, long y);
int add(long x, long y);
int subtract(long x, long y);
long x;
long y;
int main()
{
char temp[900];
printf("Enter a number:\n");
fgets(temp, sizeof temp, stdin);
x=atoi(temp);
printf("Enter another number:\n");
fgets(temp, sizeof temp, stdin);
y=atoi(temp);
multiply(x,y);
divide(x,y);
add(x,y);
substract(x,y);
}
int multiply(long x, long y)
{
int answer;
answer=x*y;
printf("i times %i is %i\n", x, y, answer);
}
int divide(long x, long y)
{
int answer;
answer=x/y;
printf("%i divided by%i is %i\n", x, y, answer);
}
int add(long x, long y);
{
int answer;
answer=x+y;
printf("%i plus %i is %i\n", x, y, answer);
}
int subtract(long x, long y)
{
int answer;
answer=x-y;
printf("%i minus %i is %i\n", x, y, answer);
}
I got this code from a c tutor but when try compile i get:
"dokimi10.c", line 4: syntax error at or near type word "long"
"dokimi10.c", line 5: syntax error at or near type word "long"
"dokimi10.c", line 6: syntax error at or near type word "long"
"dokimi10.c", line 7: syntax error at or near type word "long"
"dokimi10.c", line 30: syntax error at or near type word "long"
"dokimi10.c", line 37: syntax error at or near type word "long"
"dokimi10.c", line 44: syntax error at or near type word "long"
"dokimi10.c", line 47: illegal initialization
"dokimi10.c", line 47: cannot recover from earlier errors: goodbye!
please tell why do i got these erroes,
should i add ";" at int "work"(long x, long y)??