Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5.4.2 Exercise 2: Printing a Table Write a program that asks the user for 2 floating point numbers and 2 integer numbers and then displays

image text in transcribed
5.4.2 Exercise 2: Printing a Table Write a program that asks the user for 2 floating point numbers and 2 integer numbers and then displays them in 2 tables using the format characters for the printf function. (Refer to section 6.5.1 in the theory portion of the course pack). Enter ist float: 24.67895 Enter 2nd float: -4.123 Enter ist integer: 72 Enter 2nd integer: -14 Float Output: lut 2nd Basic 18.00 24.678949 : 24.68 -4.123888 -4.12 .8.8888 24.6789 -4.1238 1 Int ! Basic Boxx -300xx ist 2nd 72188872 -14100014 08072 -88814 Press enter to end. Note: The above example uses a " | "space, bar, space) between each column. No other spaces should be used to achieve these tables. 1 Column .8 characters wide (plus "1") ("Floar" or "In") left justified 2nd Column ("Basic") 12 characters wide (plus | 9 displays all decimal places right justified 3 Column 12 characters wide (plus "1") ("0.00" or "000ce") . floating point numbers are displayed to 2 decimal places integer numbers are displayed as a minimum of 5 digits (pads with leading zeros) left justified 4th Column 12 characters wide (plus ") ("+0.0000" or "+000xx") floating point numbers are displayed to 4 decimal places integer numbers are displayed as a minimum of 5 digits integer & floating numbers will always display their sign (+/-) tight justified Example: The following line of code will print the first heading for the table above: printf( %88%128 %12s | %125", "Floar", "Basic", "0.00", "+0.0000"); Note: Review Section 6.5 for formatting options using the printf() function. Page 36 Lab - Introduction to Programming 11 NAIT CPN1149

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

Students also viewed these Databases questions