C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 21, Problem 21.9E
Program Plan Intro
- Initialize the variables.
- Use C++ header library function <iomanip> to manipulate the streams of data and replaces the header file <iomanip.h>
- Setw stream manipulator is used to set the width of the files.
- Initialize also the field values.
- Create statement for to test the output in the various fields of lengths.
- Display the sample output.
Summary Introduction- This program test the results of printing the integer values 12345 and the floating point values that is 1.2345 in various fields of sizes.
Program Description- The purpose of the program is to test the results of printing the integer values 12345 and the floating point values that is 1.2345 in various fields of sizes.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Limitations of Floating-Point Numbers for Monetary Amounts) Section 4.6 cautionedabout using floating-point values for monetary calculations. Try this experiment: Create a floatvariable with the value 1000000.00. Next add to that variable the literal float value 0.12f. Displaythe result using printf and the conversion specifier "%.2f". What do you get?
(Integer) Bit Operators. Write a program that takes begin and end values and prints out a decimal, binary, octal, hexadecimal chart like below. If any of the characters are printable ASCII characters, then print those, too. If none is, you may omit the ASCII column header.
(Inputting Decimal, Octal and Hexadecimal Values) Write a program to test the inputtingof integer values in decimal, octal and hexadecimal formats. Output each integer read by the program in all three formats. Test the program with the following input data: 10, 010, 0x10.
Chapter 21 Solutions
C How to Program (8th Edition)
Ch. 21 - (Write C++ Statements) Write a statement for each...Ch. 21 - (Inputting Decimal, Octal and Hexadecimal Values)...Ch. 21 - Prob. 21.8ECh. 21 - Prob. 21.9ECh. 21 - Prob. 21.10ECh. 21 - Prob. 21.11ECh. 21 - (Converting Fahrenheit to Celsius) Write a program...Ch. 21 - In some programming languages, strings are entered...Ch. 21 - Prob. 21.14ECh. 21 - Prob. 21.15E
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Average a Sequence of Integers) Write a program that calculates and prints the average ofseveral integers. Assume the last value read with scanf is the sentinel 9999. A typical input sequencemight be10 8 11 7 9 9999indicating that the average of all the values preceding 9999 is to be calculatedarrow_forward(Printing with Field Widths) Write a program to test the results of printing the integer value 12345 and the floating-point value 1.2345 in various-sized fields. What happens when the valuesare printed in fields containing fewer digits than the values?arrow_forward(Compute 7) You can approximate 7 by using the following series: 1 1 1 1 6 x (1 + TT = + + .. . 4 9. 16 25 Write a program that displays the T value for n = 100, 200, ..., and 600.arrow_forward
- (Sum a Sequence of Integers) Write a program that sums a sequence of integers. Assume thatthe first integer read with scanf specifies the number of values remaining to be entered. Your program should read only one value each time scanf is executed. A typical input sequence might be5 100 200 300 400 500where the 5 indicates that the subsequent five values are to be summed.arrow_forward3. (Tabular Output) Write a Java application that uses looping to print the following table of(Exercise 4.22) values: 1 4 9 16 25 1 8 27 64 125 1 16 81 256 625arrow_forward(java programming language) Write a program to read and store four student’s 21SP registered course and their grade point, sortthem into an order their 21SP registered course, based on grade point from the smallest to the largest,then print them out. The student’s 21SP registered course and their grade point values should be typedin by the user in response to a prompt message. Save the file as SortCourse_yourID.javaarrow_forward
- (Guess the Number Modification) Modify the program of Exercise 5.32 to count the number of guesses the player makes. If the number is 10 or fewer, print Either you know the secret oryou got lucky! If the player guesses the number in 10 tries, then print Ahah! You know the secret!If the player makes more than 10 guesses, then print You should be able to do better! Why shouldit take no more than 10 guesses? Well, with each “good guess” the player should be able to eliminatehalf of the numbers. Now show why any number 1 to 1000 can be guessed in 10 or fewer tries.arrow_forward(Guess the Number) Write a C program that plays the game of “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range1 to 1000. The program then types:I have a number between 1 and 1000.Can you guess my number?Please type your first guess.arrow_forward(Rounding Numbers) Function floor can be used to round a number to a specific decimal place. The statementy = floor(x * 10 + 0.5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + 0.5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines fourfunctions to round a number x in various ways:A. roundToInteger(number)B. roundToTenths(number)C. roundToHundredths(number)D. roundToThousandths(number)For each value read, your program should print the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth.arrow_forward
- (Bar-Chart Printing Program) One interesting application of computers is drawing graphsand bar charts. Write a program that reads five numbers (each between 1 and 30). For each numberread, your program should print a line containing that number of adjacent asterisks. For example,if your program reads the number seven, it should print *******.arrow_forward(Financials: currency exchange) Write a program that prompts the user to enter the exchange rate from currency in U.S. dollars to Rupees PKR. Prompt the user to enter 0 to convert from U.S. dollars to Rupees PKR and 1 to convert from Rupees PKR and U.S. dollars. Prompt the user to enter the amount in U.S. dollars or Rupees PKR to convert it to Rupees PKR or U.S. dollars, respectively. Use c++ program.arrow_forward(Rounding Numbers) An application of function floor is rounding a value to the nearestinteger. The statementy = floor(x + .5);will round the number x to the nearest integer and assign the result to y. Write a program that readsseveral numbers and uses the preceding statement to round each of these numbers to the nearestinteger. For each number processed, print both the original number and the rounded number.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License