hi I'm a beginner in C (specifically the syntax) so I started to go through the tutorials first
everything's fine but i'm having a small problem with printf. what I exactly dont know how to do is use printf so that I can display 2 variables and not just one
here's some sample code, ( I don't know how to fix it )
its obvious, but I'm just trying to compare 2 numbers
note: this is only a part of main(), everything works when compiled, just having troubles with syntax in the bolded lines.
Code:
printf("Enter number 1: ");
scanf("%d", &num1);
printf("Enter number 2: ");
scanf("%d",&num2);
if(num1>num2)
{
printf("%d",num1,"is greater than %d", num2);
}
else if (num2>num1)
{
printf("%d",num2,"is greater than %d", num1);
}
else
{
printf("Both numbers are equal");
}
What Im trying to do is display both numbers inputted into 1 printf function, but this doesnt work the way I need it, it just shows 1 number and nothing else.
Thanks