Question

2. write the conversion (format) specifier that would be used to print the following (a) a hexadecimal integer in a field of width 3 (b) a short integer in a field of width 5 that is left justified (c) a floating point value left justified, of width 6 and outputted to the tenths osition
0 0
Add a comment Improve this question Transcribed image text
Answer #1

After %, number indicates width and sign before indicate justification( - for left and nothing right). For float/double values number after decimal indicates the no. of digits to come after decimal point.

(a) printf("%3x", x);

(b) printf("%-5d", b);

(c) printf("%-6.1f", a);

Add a comment
Know the answer?
Add Answer to:
2. write the conversion (format) specifier that would be used to print the following (a) a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignnment #1 Your Very First C++ Program Write a C+program to achieve the followings. Start a new line for each...

    Assignnment #1 Your Very First C++ Program Write a C+program to achieve the followings. Start a new line for each output a. Declare an integer and assign it with a value 45876 b. Prompt the user to input a floating point number of value 345.24681359 Display the message "Welcome to the 2019 EECE 4272 Summer Class!" c. d. Display the number from part (a) with the following format: () fixed floating-point number, (i) 2 digits after the decimal point, (ii...

  • File Edit Insert Format Arrange View Share Window Help Untitled 13-Edited View Zoom Insert Table Chart...

    File Edit Insert Format Arrange View Share Window Help Untitled 13-Edited View Zoom Insert Table Chart Text Shape Media Comment Write a regular expression for numeric constants in C. These are octal, decimal, or hexadecimal integers, or decimal or hexadecimal floating-point values An octal integer begins with 0, and may contain only the digits 0-7. A hexadecimal integer begins with 0x or OX, and may contain the digits 0-9 and a/A-1/F. A decimal floating-point value has a fractional portion (beginning...

  • Regular Expressions Write a regular expression for numeric constants in C. These are octal, decimal, or...

    Regular Expressions Write a regular expression for numeric constants in C. These are octal, decimal, or hexadecimal integers, or decimal or hexadecimal floating-point values. An octal integer begins with 0, and may contain only the digits 0-7. A hexadecimal integer begins with 0x or 0X, and may contain the digits 0-9 and a/A-f/F. A decimal floating-point value has a fractional portion (beginning with a dot) or an exponent (beginning with E or e). Unlike a decimal integer, it is allowed...

  • The following EBNF rules are a simplified version of the ones that are used to define...

    The following EBNF rules are a simplified version of the ones that are used to define hexadecimal floating-point literals in the Swift language. Design a state diagram to recognize these literals. <hexadecimal-floating-point-literal> -> <hexadecimal-literal> [ <hexadecimal-fraction> ] <hexadecimal-exponent> <hexadecimal-literal> -> 0x <hexadecimal-digit> { <hexadecimal-digit> } <hexadecimal-digit> -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f | A...

  • 2.Convert the following binary numbers to floating-point format using single-precision IEEE 754 format. Convert your answer...

    2.Convert the following binary numbers to floating-point format using single-precision IEEE 754 format. Convert your answer to hexadecimal format.   a)     11001.0101          b)     -101.111101         c)     -0.0101001

  • The utility department of Brentwood City needs you to write a C++ program that will print...

    The utility department of Brentwood City needs you to write a C++ program that will print out a customer's bill. The program should input the following items from the file named "utility.txt" (which you may copy from the class data share or Blackboard): The customer number (6-digit integer) The number of gallons of water used (floating-point, no more than 999.99) The number of kilowatts of electricity used (integer, no more than 999) The number of cubic feet of natural gas...

  • To write a C program (not C++) that converts numbers between Decimal and IEEE-754 format and...

    To write a C program (not C++) that converts numbers between Decimal and IEEE-754 format and vice versa. Inputs: Number in Decimal format (including special case of 0) Number in IEEE-754 format (including special cases) Output: Equivalent number in IEEE-754 format Equivalent number in Decimal Specification: The program converts a number based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are: Decimal to IEEE-754 conversion IEEE-754 to Decimal conversion Quit program...

  • this is in C programming language 1. Write a printf or scanf statement for each of...

    this is in C programming language 1. Write a printf or scanf statement for each of the following: a) Print unsigned integer 1001 right justified in a 10-digit field with 5 digits. b) Read a hexadecimal value into variable hex. c) Print 300 with and without a sign. .d) Print 200 in hexadecimal form preceded by Ox. e) Read characters into array m until the letter z is encountered. f) Print 7.350 in a 7-digit field with preceding zeros. B)...

  • Problems: 1. Write a program to define the following variables, assign them values, and print their...

    Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...

  • C PROGRAMMING      Write a printf or scanf statement for each of the following: a) Print...

    C PROGRAMMING      Write a printf or scanf statement for each of the following: a) Print unsigned integer 2001 right justified in a 12-digit field with 6 digits. b) Print 3.150 in a 9-digit field with preceding zeros. // part of my answer: Printf(“%09 c) Read a time of the form hh-mm-ss, storing the parts of the time in the integer variables hour, minute and second. Skip the dash (-) in the input stream. Use the assignment suppression character. d)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT