Computer Science, asked by deshmukhharshad2004, 1 month ago

What is the output of C Program.?
int main()
{
int a=9;
if(a=8)
{
printf("Kangaroo\n");
}
printf("Eggs\n");

return 0;
}
=======================================
A) No output
B) Eggs
C) Kangaroo
Eggs
D) Compiler error​

Answers

Answered by dapushree
1

Answer:

option C is correct

Explanation:

becoz value will be change due to initialization of variable a... hence , kangaroo will print on the screen and again Eggs will print also

Answered by varshamittal029
0

Answer: Option (C) is correct.

Concept:

The object provided by the left operand takes a value using assignment operators and this operator returns the assigned value.

Find:

What is the output of the given program?

Solution:

As a=8 is an assignment statement, it will return the assigned value 8.

The if condition will become true for any number except for 0.

Therefore, statements under if condition will get executed.

So, print("Kangaroo\n") will get executed, and then  print("Eggs\n").

Output:

Kangaroo

Eggs

Hence, option (C) is correct.

Similar questions