Answer to Question #60864 in C for pranav

Question #60864
main( )
{
int x = 3, y, z ;
y = x = 10 ;
z = x < 10 ;
printf ( "\nx = %d y = %d z = %d", x, y, z ) ;
}
1
Expert's answer
2016-07-18T07:34:49-0400

In order that the program was started and the compiler did not give an error message it is necessary, first to connect library in which there is a printf function. For this purpose it is necessary over main () to write such line: #include <stdio.h>.
The directive #include connects standard libraries, in our case it is stdio.h library in which there is a printf function. Secondly, before the name of the main function () it is necessary to write type value which is returned by this function. Main () returns 0 if comes to the end successfully, that is an integer number. Its type - int. This line has to be is as follows: int main (). After these steps the program will be successfully compiled and it can be started on accomplishment.
Explanation on a program code: we have a declaration of 3 variables with the int type, that is 3 variables which will save value of an integer number. At once at the declaration x receives value 3. In the second line of the program y and x receive identical value: number 10. In the 3rd line z expression receives result x <10. As x at us it is equal 10, expression 10 <10 will be false, and the result false expression is 0. That is z will receive value 0. The last line we display value of variables through library function of printf. In quotes is a line of a format. Here we specify how to interpret value of variables. \n means word wrapping; x =, y =, z = will be displayed as it is written; %d is a qualifier which specifies that variables which go after a line of a format will be displaid as integer numbers.

The result of a program runtime will be such:
x = 10 y = 10 z = 0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS