Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, we will investigate the use of format specifiers to control the way that output appears on the screen. When printing values of

image text in transcribedimage text in transcribed

In this exercise, we will investigate the use of format specifiers to control the way that output appears on the screen. When printing values of type double, format specifiers have the following form, in general: "s.X.Ylf" with a+ or - sign optionally appearing before the X. Y represents a positive integer that controls the number of decimal places that are displayed. If Y is not specified, the default number of decimal places is 6 . So, "\%lf" indicates that the number is to be printed to 6 decimal places. X represents a positive integer that controls the minimum width of the field in which the number is to be displayed. If X is not specified, the number is displayed in a field just wide enough to print the number to the specified (or default) number of decimal places. So, "8 f " indicates that the number is to be printed in a field of width 8 characters. Note that the number is aligned on the right-hand side of the field, by default, and spaces are added to the left, if required, to fill the minimum width. If there's a - sign in front of the x, the number is aligned on the left-hand side of the field in which it is printed-in other words, spaces are added to the right of the number. If there's a + sign in front of the x, the sign of the number is always printed. So, if the number is positive, a+ sign will be printed immediately preceding the number. Suppose the following variable declarations have been made: double a=2.6680000992176423; Determine the output from each of the following printf statements. The first two are done for you make sure you understand them before you move on. Note that the correct number of spaces (before, after and in the middle) is required for your answer to be considered correct. Don't forget to round the numbers as appropriate

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions