What is the output of the following statement?
x=y=z=0;
Select one:
1)x=0, y=NULL, Z=NULL
2)The statement is incorrect
3)x=0, y=0, z=0
4)x=0, y=1, z=2
Answers
Answer:
you need to work hard because this question is very simple...
Explanation:
3)x=0, y=0, z=0
The output of the following statement is x=0, y=0, z=0
3) x=0, y=0, z=0
Explanation
The whole códe will be
#include <stdio.h>
int main()
{
int x, y, z;
x=y=z=0;
printf("x = %d, y = %d, z = %d", x, y, z);
return 0;
}
Output of the códe
x = 0, y = 0, z = 0
In the códe, three variables that are x, y, and z are defined with data type int
In the next statement which is x=y=z=0;
'x' is assigned 'y' variable value
'y' is assigned 'z' variable value
'z' is assigned a value 0
Now, as the value of variable 'z' is 0 then we can conclude that the value of variable 'x' and 'y' will also be 0 as y = z and x = y
Extra Information
There are various types of format specifier in C which is used to either take the input from the user or to show output to the user. Some common format specifiers are
1. %d
This format specifier is used for integer values or int values
2. %c
This format specifier is used for characters.
3. %s
This format specifier is used for string
4. %f
This format specifier is used for float values or decimal values.