Social Sciences, asked by Mohit0000, 1 year ago

What is the output of this C code?

#include <stdio.h>
main()
{
int n = 0, m = 0;
if (n > 0)
if (m > 0)
printf("True");
else
printf("False");
}​

Answers

Answered by dassristi2016
3

#include <stdio.h>

int main()

{

float f = 0.1;

if (f == 0.1)

printf("True");

else

printf("False");

return 0;

}

The output is false.

#include <stdio.h>

int main()

{

float f = 0.1;

if (f == (float)0.1)

printf("True");

else

printf("False");

return 0;

}

Now shows the correct output. Whats the reason behind this?

Also what is the reason of this behavior.

#include <stdio.h>

main()

{

int n = 0, m = 0;

if (n > 0)

if (m > 0)

printf("True");

else

printf("False");

}

Answered by remyanairlm
0

Answer:

The above program will give the output as False.

Explanation:

The given program is as follows:

#include <stdio.h>

main()

{

int n = 0, m = 0;

if (n > 0)

if (m > 0)

printf("True");

else

printf("False");

}​

The above program will give the output as False.

This is because both n=m=0 and therefore, the if condition is not satisfied and hence, the else condition will get executed.

The answer is False.

Similar questions