Question

Assignnment #1 Your Very First C++ Program Write a C+program to achieve the followings. Start a new line for each output a. D
Add the question number, remove the code that you used for testing, and combine the cout statements.
answer questions e, f, g, h ,i,j. only |
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 a field width of 12, (iv) fill empty space withA' Display the number from part (a) with the following format: (i scientific floating-point numher, (ii) 3 digits after the decimal point, (ii) a field width of 10, (iv) fill empty space e. with f Display the number from part (a) with the following format: () default floating-point number, (ii) 4 digits after the decimal point g. Display the floating number in part (a) as 345.2 h. Display the floating number in part (a) as bb345.247. i. Display the floating number in part (a) with 4 digits to the right of the decimal point and 4 leading characters **345.2468 j. Display the integer in part (b) in hexadecimal
Add the question number, remove the code that you used for testing, and combine the cout statements.
answer questions e, f, g, h ,i,j. only |
0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOURCE CODE:

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
float a=345.24681359;
std::cout << std::setprecision(3);
cout<<"Question e "<<std::scientific<<endl;
cout<<std::setfill('_')<<std::setw(10);
cout<<a;
cout<<endl;

std::cout << std::setprecision(4);
cout<<"Question f "<<std::defaultfloat<<endl;
cout<<a;
cout<<endl;
cout<<"Question g "<<std::defaultfloat<<endl;
cout<<a;
cout<<endl;
std::cout << std::setprecision(3);
cout<<"Question h "<<std::fixed<<endl;
cout<<"bb"<<a;
cout<<endl;
std::cout << std::setprecision(4);
cout<<"Question i "<<std::fixed<<endl;
cout<<std::setfill('*')<<std::setw(12);
cout<<a;
cout<<endl;
cout<<"Question j "<<std::hexfloat<<endl;
cout<<a;
cout<<endl;
return 0;
}

SCREENSHOTS:

main.cpp [test]- Code::Blocks 17.12 Eile Edit View Search Project Build Debug Fortran wSmith Iools Tools Plugins DogyBlocks SQuestion e 3.452e+002 Question f 345.2 Question g 345.2 Question h bb345.247 Question i ***345.2468 Question j 8e-307

Add a comment
Know the answer?
Add Answer to:
Assignnment #1 Your Very First C++ Program Write a C+program to achieve the followings. Start a new line for each...
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
  • Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display...

    Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...

  • Write a C program which will display the contents of a file in base-16 (hexadecimal) and...

    Write a C program which will display the contents of a file in base-16 (hexadecimal) and in ASCII. Complete the following tasks: Obtain the name of the input file from the command line. If the command-line is “./hexdump xxx.bin” then argv[1] will contain “xxx.bin”. Open the file for binary input Print the entire file, 16-bytes per line. Each line should begin with an 8-digit hexadecimal offset into the file. This is the count of the bytes that you have already...

  • (1) (50%) Write a C program that takes as input a fully parenthesized, arithmetic expression of...

    (1) (50%) Write a C program that takes as input a fully parenthesized, arithmetic expression of binary operators +, -,*,/, and converts the expression into a binary expression tree. Your program should take input from the command line. The entire expression should be in a character string without any space in it An input string only includes floating numbers in the format of Y.YY, that is, one digit to the left of the decimal point and two digits to the...

  • Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write...

    Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write a program to ask the user for a number that includes a decimal point. Then display the integer part of the number (the part of the number to the left of the decimal point) and the decimal part of the number (the part of the number to the right of the decimal point, including the decimal point Follow the 3 steps in the Information...

  • 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...

  • 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...

  • write a C program that evaluate algebraic expressions over real numbers in Reverse Polish Notation (RPN)

    Your program must evaluate algebraic expressions over real numbers in Reverse Polish Notation (RPN). + (addition), - (subtraction), * (multiplication) and / (division) should be treated as arithmetic operations. Depending on the selection, numerical values must be entered and displayed in decimal, hexadecimal or binary form. Example: The expression ((3+4) *(7+1.6-12) -5) / (3-8.7)Will be calculated on your RPN calculator as 3 4 + 7 1.6 + 12 - * 5 - 3 8.7 - / Your RPN computer's user...

  • A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is...

    A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output is the miles walked. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f}'.format(your_value)) Ex: If the input is: 5345 the output is: 2.67 Your program must define and call the following function. The function should return the amount of miles walked. def steps_to_miles(user_steps) answer must be in Phython...

  • The answer below is correct, but can you guys show me how to get it? I...

    The answer below is correct, but can you guys show me how to get it? I need conplete solution. thanks Consider a 16-bit floating-point representation based on the IEEE floating-point format, with one sign bit, seven exponent bits (k=7), and eight fraction bits (n:8). The exponent bias is 27-1-1-63. Fill in the table that follows for each of the numbers given, with the following instructions for each column: Hex: the four hexadecimal digits describing the encoded form. M the value...

  • **This is for the C Language. Trigonometric Calculator Specification You are required to write a program...

    **This is for the C Language. Trigonometric Calculator Specification You are required to write a program that calculates and displays values of the trigonometric functions sine, cosine, and tangent for user-supplied angular values. The basic program must comply with the following specification. 1. When the program is run, it is to display a short welcome message. TRIG: the trigonometric calculator 2. The program shall display a message prompting the user to enter input from the keyboard. Please input request (h-help,...

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
ADVERTISEMENT