Question

In: Computer Science

Practice basic output formatting by reproducing the output below. All floating-point numbers should have 3 decimal...

Practice basic output formatting by reproducing the output below. All floating-point numbers should have 3 decimal places. Use these constants and values: NUM1= 10, NUM2= 1.49, and NUM3= 12.538767

Output:

NUM1 NUM2 NUM3
10 1.490 12.539

------------------------

123456789012345678901234 <-- DO NOT output this area. It is here to help you align things.

------------------------

Solve in C++.

Solutions

Expert Solution

#include<stdio.h>
#include<iostream>

using namespace std; \
int main()
{
        float num1=10;
        float num2=1.49;
        float num3=12.538767;
        
        //%-Xs : - sign puts the string to left side  X denotes number of space occupy  and s represents string 
        printf("%-10s%-10s%-10s\n","NUM 1","NUM 2","NUM 3");
        
        // %-X.Yf  : - sign puts number to left  X denotes number of space occupied by whole number  Y represent space occupied after decimal
        printf("%-10.3f%-10.3f%-10.3f\n",num1,num2,num3);

        return 0;
}

IF YOU HAVE ANY DOUBT THEN JUST LEAVE A COMMENT AND I WILL CLEAR YOUR DOUBT.


Related Solutions

**C++** Output each floating-point value with two digits after the decimal point, which can be achieved...
**C++** Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements. (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (2 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear...
3. IEEE Floating Point Representation What decimal number does the 32-bit IEEE floating point number 0xC27F0000...
3. IEEE Floating Point Representation What decimal number does the 32-bit IEEE floating point number 0xC27F0000 represent? Fill in the requested information in the blanks below. What is the sign of the number (say positive or negative): What is the exponent in decimal format: What is the significand in binary: What is the value of the stored decimal number in decimal (final answer): Credit will be given for your final answer in the blanks and the work shown below.
represent the decimal number 101 and 6 as floating point binary numbers please show your work...
represent the decimal number 101 and 6 as floating point binary numbers please show your work and explained, I have a test.
12. The reciprocal search problem is: input: a list L of n floating point numbers output:...
12. The reciprocal search problem is: input: a list L of n floating point numbers output: two elements a, b L such that a*b=1, or None if no such a, b exist Design an algorithm for this problem using the greedy pattern. Write pseudocode for your algorithm below. If you write multiple drafts, circle your final draft. Hint: I expect your algorithm to be relatively simple and to have time complexity O(n2). 13. Perform a chronological step count to derive...
Convert the following decimal numbers into their 32-bit floating point representation (IEEE single precision). You may...
Convert the following decimal numbers into their 32-bit floating point representation (IEEE single precision). You may use a calculator to do the required multiplications, but you must show your work, not just the solution. 1. -59.75 (ANSW: 11000010011011110000000000000000) 2. 0.3 (ANSW: 00111110100110011001100110011010 (rounded) 00111110100110011001100110011001 (truncated; either answer is fine)) Please show all work
Represent the following decimal numbers using IEEE-754 floating point representation. A. -0.375 B. -Infinity C. 17...
Represent the following decimal numbers using IEEE-754 floating point representation. A. -0.375 B. -Infinity C. 17 D. 5.25
Convert the following decimal numbers to 32-bit IEEE floating point: 86.59375 -1.59729 Convert the following 32-bit...
Convert the following decimal numbers to 32-bit IEEE floating point: 86.59375 -1.59729 Convert the following 32-bit IEEE floating point numbers to decimal: 0100 1100 1110 0110 1111 1000 0000 0000 1011 0101 1110 0110 1010 0110 0000 0000
Convert the following 32-bit IEEE floating point numbers to decimal: 0100 1100 1110 0110 1111 1000...
Convert the following 32-bit IEEE floating point numbers to decimal: 0100 1100 1110 0110 1111 1000 0000 0000 1011 0101 1110 0110 1010 0110 0000 0000 Determine whether or not the following pairs are equivalent by constructing truth tables: [(wx'+y')(w'y+z)] and [(wx'z+y'z)] [(wz'+xy)] and [(wxz'+xy+x'z')] Using DeMorgan’s Law and Boolean algebra, convert the following expressions into simplest form: (a'd)' (w+y')' ((bd)(a + c'))' ((wy'+z)+(xz)')' Draw the circuit that implements each of the following equations: AB'+(C'+AD')+D XY'+WZ+Y' (AD'+BC+C'D)' ((W'X)'+(Y'+Z))'
Find the 3-bit mantissa floating point representation of the following numbers, both by chopping and rounding,...
Find the 3-bit mantissa floating point representation of the following numbers, both by chopping and rounding, and then calculate the associated respective absolute error and relative error: (a) 11/16 (b) 2.75
3) Convert 1.25 decimal to 32 bit floating point format. 4) Convert the following truth table...
3) Convert 1.25 decimal to 32 bit floating point format. 4) Convert the following truth table to a digital circuit consisting of NOT, AND, and OR gates. ABC Out 000 1 001 1 010 0 011 0 100 1 101 0 110 1 111 0 5) Construct a tri-state buffer using transistors 10) What are the advantages of a large page size?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT