What is the output of the following code? [code]sprintf(‘%E’,912)[/code]

Nguyễn Tân

New member
What is the output of the following code?
Code:
sprintf(‘%E’,912)
A. 9.120000E+02
B. 9.120E+02
C. 9.1200E+02
D. 9.12000E+02
 
Answer: a
Explanation: If we don’t mention a precision amount, the default number of digits shown after the decimal place will be 6. Hence, option 9.120000E+02 is correct only. Option 9.120E+02 is true for %.3E used as the format specifier.
Output: 9.120000E+02
 

Tìm kiếm

Back
Top