i JUST started C a few days ago.
i decided, after reading a prog in a book i have, to make a program to either multiply or divide two ints depending on user input.
so i wrote the program, got like 14 compile errors, fixed most of em
now im down to 2-4 compile errors, and i just cant figure them out.
either they r too cryptic, or i just don understand yet.
here are the errors, if you need program source i will post:
c:\docume~1\galgar~1\desktop\untitl~1.cpp: In function `int main()':
c:\docume~1\galgar~1\desktop\untitl~1.cpp:17: parse error before `else'
c:\docume~1\galgar~1\desktop\untitl~1.cpp: At top level:
c:\docume~1\galgar~1\desktop\untitl~1.cpp:22: parse error before `return'
actually, here is source:
please tell me what im doing wrong... i cant figure it out.Code:#include <stdio.h> int num1, num2, num3, num4; int product(int x, int y); int divide(int z, int a); int main( void ) { printf ("pick Multiply, divide(1,2):"); scanf ("%d", &num4); printf ("enter a number:"); scanf ("%d", &num1); printf ("Enter another number:"); scanf ("%d", &num2); if (num4 == 1) num3=product(num1,num2); printf ("total multiplied is: %d",num3); else { num3=divide(num1,num2); printf ("total divided is: %d",num3); } return 0; } int product(int x,int y) { return (x*y); } int divide(int z, int a) { return (z/a); }
Thanks in Advance,
Phate



LinkBack URL
About LinkBacks


