According to the operation entered from the keyboard, I want to do 5 operations with the switch structure, but gives an error. I tried also getchar & putchar functions...
int main()
{
char proc;
int firstNum,secondNum,result;
printf("* Multiplication\n/ Division\n+ Add \n- Minus\n%c Mode", '%');
printf("\nEnter the first number: ");
scanf("%d",&firstNum);
printf("\nEnter the second number: ");
scanf("%d",&secondNum);
printf("\nEnter the process: ");
scanf("%c",&proc);
switch(proc) {
case '*':
result=firstNum*secondNum;
printf ('%d',result);
break;
case '/':
result=firstNum/secondNum;
printf ('%d',result);
break;
case '+':
result=firstNum+secondNum;
printf ('%d',result);
break;
case '-':
result=firstNum-secondNum;
printf ('%d',result);
break;
case '%':
result=firstNum%secondNum;
printf ('%d',result);
break;
default:
printf('Warning!');
break;
}
warning: multi-character character constant [-Wmultichar]
warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast [-Wint-conversion]
For starters use
scanf(" %c",&proc);
^^^
(see the blank before the character &) instead of
scanf("%c",&proc);
And use double quotes to specify string literals in statements like this
printf ( "%d",result);
^^^^
or this
printf("Warning!");
^^^ ^^^
And you forgot one closing brace in the end of the program.