Hw5 - a printf-10d\n 10000 10000 3(Ch.8 Problem 2 When printing b printf%c\n"This is a string a float or double using function p printf with the

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EME Homework 5 (3-13) 3. (Ch.8, Problem 2) When printing a float or double using function printf() with the format specifier “%f” , how many digits are there after the decimal point in output? Does printf() round or truncate the value? 4. (Ch.8, Problem 3 a-e) Show what is printed by each of the following statements. If a statement is incorrect, explain why. 5. (Ch.8, Problem 4 a, b, c, d, h) Write a printf or scanf statement for each of the following: There are 6 digits after the decimal point; printf( ) rounds the value. a.) printf(“%-10d\n”, 10000); 10000 b.) printf(“%c\n”, “This is a string”); p Incorrect; should be %s to print out a string, not %c which prints out a character. c.) printf(“%*.*lf\n”, 8, 3, 1024.978654); 1024.979 d.) printf(“%\#o\n%#X\n%#e\n”, 17, 17, 1008.83689); WARNING: dubious escape '\#' 021 0X11 1.008837e+003 Incorrect; need to take out the first backslash. e.) printf(“% ld\n%+ld\n”, 100000, 100000); 1000000 +1000000 a.) Print unsigned integer 40000 left justified in a 15-digit field. > printf(“%-15i”, 40000);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 04/21/2008 for the course EME 005 taught by Professor Cheng during the Fall '07 term at UC Davis.

Page1 / 8

Hw5 - a printf-10d\n 10000 10000 3(Ch.8 Problem 2 When printing b printf%c\n"This is a string a float or double using function p printf with the

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online