+ 2
Int main (). { int i=20,j=10; if(I<10); I=i-5; j=j-5;printf("%d %d \n",I,j);
What is output
18 Réponses
+ 3
Why not try it?
By the way there are some error I found like semicolons in " if " condition and some uppercases.
https://code.sololearn.com/cA10A157A5A1
+ 2
Ankit Kumar
OK I know where you are getting into.
You expect the output to be 15 5 right?
Then it is because the if statement is False
- - - - - - - - - - - - - - -
i = 20
if (i < 10) - - -> This is False
- - - - - - - - - - - - -
Therefore the code below it will not be executed and the value of both i and j will not be substracted by 5. Make the value of i less than 10 to make it happen.
I hope you now get it. Happy Coding!
+ 1
Ankit Kumar, try it in the code playground please!
+ 1
20 10
+ 1
《 Nicko12 》just gave you the answer.
+ 1
If there is semicolon after "if" statement the answer will be
15 5
+ 1
It is because there is semicolon at the end of "if" statement that means the statements after "if" will execute irrespective of the condition
+ 1
Are you not getting 15 5?
+ 1
sai vamsi Yeah I also got 15 5
But in my first code it outputs 20 10 cause the if-statement is False and did not substract the numbers so...
Ankit Kumar What output do you want anyway?
+ 1
Yes Ankit Kumar output is clear it is 15 5. What are you expecting?
0
Wrong answer not 20 10
0
15 5
0
semicolon after if statement it is null statement and excute 15 5
0
Write sai
0
Ap code kar dekh ligye
0
Ankit Kumar
Here output will be different.
https://code.sololearn.com/cx6eHpQWM8nr/?ref=app
0
int main()
{
int i=20,j=10;
if(i<10);---->semicolon means termination so this condition will not be considered .
i=i-5;//i=15
j=j-5;//j=5
printf("%d%d",i,j);
hence output will be 15,5
- 1
Any one can explain it