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...
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...
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
Given below is a fictitious Excel output (numbers might be all made up) Answer the questions...
Given below is a fictitious Excel output (numbers might be all made up) Answer the questions that follow. You are being tested for your ability to read the output and your skill in sensitivity analysis as taught in class.) Variable Cells Final Reduced Objective Allowable Allowable Cell Name Value Cost Coefficient Increase Decrease $B$6 X1 45 0 12 10 8 $C$6 X2 0 -6 8 15 12 $D$6 X3 10 0 5 20 15 $E$6 X4 35 0 6 8...
Please show all work for full credit! When performing calculations, round numbers to 3 decimal places...
Please show all work for full credit! When performing calculations, round numbers to 3 decimal places The California Condor (Gymnogyps californianus) is a critically endangered species. In 1991, 48 adults individuals were released in the wild from the captive breeding program. In 2016, there were approximately 323 individuals in existence. 1.Calculate r for this time frame, assuming a continuous and constant growth rate (2 pts). 2.What is the doubling time of this population (2 pts)? 3. 30 rabbits are introduced...
For this given below discussion, you have to select all practices and for each self-care practice:...
For this given below discussion, you have to select all practices and for each self-care practice: Identify one barrier that prevents people from using the self-care practices, and provide a description of each barrier and how it can be overcome. The following are a list of self care practices. 1. Relaxation and Pampering 2. Exercise Regularly 3. Proper Nutrition 4. Adequate Sleep 5. Social Support and Relationships
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT