I was trying to make a simple c calculator because i am a newbie and thought it would be a good idea. This is my code:
#include <stdio.h>
main()
{
char b;
int a,c,d;
printf("Please enter your first number: ");
scanf("%d",&a);
printf("Please enter your second number: ");
scanf("%d",%c);
printf("Enter your operation");
scanf("%c",&b);
if (b == 'a')
{
d = a + c;
printf("The answer is: %d",d);
}
}
When i compile the code this is the error/warnings i get:
D:...|4|warning: return type defaults to 'int'|
D:...||In function 'main':|
D:...|10|error: expected expression before '%' token|
Can someone please help?
Change the
%to a&in thescanf:Also, instead of
mainyou wantint mainand you probably should return something at the end.