hi, really annoying me now, it compiles, runs, and the add or mult work with the response part, but when it says enter the 2 numbers to either add or mult, when i hit enter it does nothing, just goes down, it just wont do the caculation.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int mult ( int a, int b );
int add ( int c, int d );
int main()
{
int a;
int b;
int c;
int d;
char e[5];
printf( "Add or Mult: " );
scanf( "%s", &e );
if (strcmp ( e, "add" ) == 0 ) {
printf( "enter two numbers to be added together: " );
scanf( "%d", &c );
scanf( "%d", &d );
printf( "the product of your two numbers is %d\n", add( c , d);)}
else if (strcmp ( e, "mult" ) == 0 ) {
printf( "enter the two numbers you want to Multiply: " );
scanf( "%d", &a );
scanf( "%d", &b );
printf( "the product of your numbers is %d\n", mult( a, b ) ) ;
getchar();
}
}
int mult (int a, int b)
{
return a * b;
}
int add (int c, int d)
{
return c + d;
}