74.7k views
3 votes
What will the following C code print out?

int x = 7, y = 5;

if (x > 5)

if (y > 5)

printf(“x and y are > 5”);

else

printf(“x is <=5”);
a) “x and y are > 5”

b) “x is <=5”

c) nothing will be printed

User Reka
by
5.8k points

1 Answer

4 votes

Answer:

x is <=5

Step-by-step explanation:

If-else is the statement that is used to execute the statement when the condition is true.

syntax:

if(condition){

statement;

}else{

statement;

}

if we do not provide the curly bracket, still the statement is valid.

in the question, x =7 and y=5

then, check the condition 7 > 5 condition true. it moves to the next if statement and check 5 > 5, condition false. Then it moves to the else part and executes the statement.

and print the output "x and y are > 5".

User Frank Hu
by
5.0k points