riables x and p have been declared as floating-point variables. Note that the way the value of 1.234567890000 that we assigned to x is displayed under different output formats. The value of x is displayed as 1.234567880630 under %.12lf format, while the actual value assigned is 1.234567890000. This is because the variable x has been declared as a float that can store values only upto six decimal places.The variable m that has been declared as int is not able to store the value 54321 correctly. Instead, it contains some garbage. Since this program was run on a 16-bit machine, the maximum value that an int variable can store is only 32767. However, the variable k (declared as unsigned) has stored the value 54321 correctly. Similarly, the long int variable n has storedt he value 1234567890 correctly.The value 9.87654321 assigned to y declared as double has been stored correctly but the valueis printed as 9.876543 under %lf format. Note that unless specified otherwise, the printf function will always display a float or double value to six decimal places. We will discuss later the output formats for displaying numbers.
The variables x and p have been declared as floating-point variables. Note that the way the value of 1.234567890000 that we assigned to x is displayed under different output formats. The value of x is displayed as 1.234567880630 under %.12lf format, while the actual value assigned is 1.234567890000. This is because the variable x has been declared as a float that can store values only upto six decimal places.The variable m that has been declared as int is not able to store the value 54321 correctly. Instead, it contains some garbage. Since this program was run on a 16-bit machine, the maximum value that an int variable can store is only 32767. However, the variable k (declared as unsigned) has stored the value 54321 correctly. Similarly, the long int variable n has storedt he value 1234567890 correctly.The value 9.87654321 assigned to y declared as double has been stored correctly but the valueis printed as 9.876543 under %lf format. Note that unless specified otherwise, the printf function will always display a float or double value to six decimal places. We will discuss later the output formats for displaying numbers.
Step by step
Solved in 2 steps