[still errors]
i have 30 errors now as change it up a bit this is the program:
CODE
#include<stdio.h>
int addition(num1,num2);
int subtraction(num1,num2);
int multiplication (num1,num2);
int division(num1,num2);
int modulos(num1,num2);
int sum,sub,mult,div,mod,largest,num1,num2;
int choice;
main()
{
printf("please enter two integers /n");
scanf("%d/n%d/n", & num1, & num2);
menu()
scanf(choice);
if(choice==1)
sum=addition("%d/n%d/n",&num1,&num2);
printf("sum is %d", sum);
else if(choice==2)
sub=subtraction("%d/n%d/n",&num1,&num2);
printf("sub is %d", sub);
if (num1>num2)
largest=num1;
else
largest=num2;
prinf("largest is %d", largest);
else if (choice==3)
mult=multiplication("%d/n%d/n",&num1,&num2);
printf("mult is %d",mult);
else if (choice==4)
{ if (num2==0)
printf("division by zero is not allowed");
else { div=division("%d/n%d/n",&num1,&num2);
printf("div is %d", div);
if (num1>num2)
largest=num1;
else
largest=num2;
printf("largest is %d", largest);
}
else if (choice==5)
{ if(num2==0)
printf("modulos by zero is not allowed");
else{ mod=modulos("%d/n%d/n",&num1,&num2);
printf("mod id %d", mod);
if (num1>num2)
largest=num1;
else
largest=num2;
printf("largest is %d", largest);
}
else if (choice==0)
printf("exiting now!!");
return 0;
}
function menu()
{
printf("please enter 1 for addition");
printf("please enter 2 for subtraction");
printf("please enter 3 for multiplication");
printf("please enter 4 for division");
printf("please enter 5 for modulos");
printf("please enter 0 for exit");
}
int addition(num1,num2)
int a;
{
a=num1+num2;
return (a);
}
int subtraction (num1,num2)
int b;
{
b=num1-num2;
return (B);
}
int multiplication (num1,num2)
int c;
{
c=num1*num2;
return ©;
}
int division(num1,num2)
int d;
{
d=num1/num2;
return (d);
}
int modulos(num1,num2)
int e;
{
e=num1%num2;
return (e);
}
and these are the errors:
C:\math.cpp(3) : error C2065: 'num1' : undeclared identifier
C:\math.cpp(3) : error C2065: 'num2' : undeclared identifier
C:\math.cpp(3) : error C2078: too many initializers
C:\math.cpp(4) : error C2078: too many initializers
C:\math.cpp(5) : error C2078: too many initializers
C:\math.cpp(6) : error C2078: too many initializers
C:\math.cpp(7) : error C2078: too many initializers
C:\math.cpp(21) : error C2065: 'menu' : undeclared identifier
C:\math.cpp(23) : error C2146: syntax error : missing ';' before identifier 'scanf'
C:\math.cpp(23) : error C2664: 'scanf' : cannot convert parameter 1 from 'int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\math.cpp(29) : error C2181: illegal else without matching if
C:\math.cpp(39) : error C2065: 'prinf' : undeclared identifier
C:\math.cpp(41) : error C2181: illegal else without matching if
C:\math.cpp(45) : error C2181: illegal else without matching if
C:\math.cpp(58) : error C2181: illegal else without matching if
C:\math.cpp(70) : error C2181: illegal else without matching if
C:\math.cpp(78) : error C2065: 'function' : undeclared identifier
C:\math.cpp(78) : error C2146: syntax error : missing ';' before identifier 'menu'
C:\math.cpp(80) : error C2143: syntax error : missing ';' before '{'
C:\math.cpp(92) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\math.cpp(95) : error C2065: 'a' : undeclared identifier
C:\math.cpp(103) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\math.cpp(105) : error C2065: 'b' : undeclared identifier
C:\math.cpp(113) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\math.cpp(115) : error C2065: 'c' : undeclared identifier
C:\math.cpp(123) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\math.cpp(126) : error C2065: 'd' : undeclared identifier
C:\math.cpp(134) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\math.cpp(137) : error C2065: 'e' : undeclared identifier
C:\math.cpp(142) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
math.obj - 30 error(s), 0 warning(s)
~Admin Edit: Added [code] tags