Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C
#include <stdio.h>

int main()
{
    int x,a,b;
    scanf("%d%d",&a,&b);
    x= a>b ? a : b;
    Return 0;
}


why is this thing not running. :(

What I have tried:

Tried running the code but not working
Posted
Updated 4-Dec-20 20:28pm
v2

"It's not working" is one of the most useless problem descriptions we get: it tells us absolutely nothing about the problem. We don't know if you get an error message, or the wrong data, or even that that code compiles successfully!
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So tell us what happens when you run that code, what you expected to happen, how you checked what happened. Help us to help you!

In this case, I'm guessing that "not working" means two things: "it doesn't compile" and
"if it did compile, it wouldn't give me a result".

It doesn't compile because C is case sensitive: "Return" is not the same as "return".
Change this:
C++
Return 0;
To this:
C++
return 0;


But ... it won't do anything!
Firstly, because you haven't told it to show you any result. Add this line immediately above the return:
C++
printf("%d:%d - %d\n", a, b, x);


Secondly, because your two inputs are "jammed up together" and it doesn't know how to separate them.
Change this:
C++
scanf("%d%d",&a,&b);
To this:
C++
scanf("%d,%d", &a, &b);
And enter your two numbers separated by a comma: "12, 14" or "666,77"
 
Share this answer
 
Comments
CPallini 17-Sep-20 6:03am    
5.
TRY THIS: // do not write this in code or even this line too



#include<stdio.h>
#include<conio.h>
void main()
{
int x,a,b;
printf("enter the values of a & b=");
scanf("%d%d", &a,&b);
x=a-b;
printf("x=%d",x);
getch();

}
 
Share this answer
 
v2
Comments
CHill60 7-Dec-20 5:45am    
Your code has the same issue as the OPs in
scanf("%d%d", &a,&b);
See Solution 1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900