1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bas_tet [7]
3 years ago
8

Assume the following variable definition appears in a program:

Computers and Technology
1 answer:
AnnZ [28]3 years ago
4 0

Answer:

cout << setprecision(2)<< fixed << number;

Explanation:

The above statement returns 12.35 as output

Though, the statement can be split to multiple statements; but the question requires the use of a cout statement.

The statement starts by setting precision to 2 using setprecision(2)

This is immediately followed by the fixed manipulator;

The essence of the fixed manipulator is to ensure that the number returns 2 digits after the decimal point;

Using only setprecision(2) in the cout statement will on return the 2 digits (12) before the decimal point.

The fixed manipulator is then followed by the variable to be printed.

See code snippet below

<em>#include <iostream>  </em>

<em>#include <iomanip> </em>

<em>using namespace std;  </em>

<em>int main()  </em>

<em>{  </em>

<em> // Initializing the double value</em>

<em> double number = 12.3456;  </em>

<em> //Print  result</em>

<em> cout << setprecision(2)<< fixed << number;  </em>

<em> return 0;  </em>

<em>}  </em>

<em />

You might be interested in
PLEASE I NEED HELP WITH THIS I WILL GIVE BRAINLIST!!!!!
Neko [114]
It would be so you like chocolate because there is only two options. Yes or no
8 0
3 years ago
Read 2 more answers
_______ and _____ are two major techniques involved in green computing. NextReset
FrozenT [24]
Green computing is the use of computers and related resources which is environmentally responsible. Energy-efficiency and e-waste are two major techniques involved in green computing. Energy efficiency involves implementation of energy-efficient central processing units (CPUs), servers and peripherals as well as reduced resource consumption. And e-waste is the proper disposal of electronic waste.


3 0
3 years ago
Read 2 more answers
What is a nonprofit organization that has assumed the responsibility for Internet Protocol (IP) address space allocation, protoc
Sloan [31]

Answer:

ICANN

Explanation:

The Internet Corporation for Assigned Names and Numbers (ICANN) is saddled with the responsibility of allocating IP addresses among other duties.

Cheers

6 0
4 years ago
You receive a check on which the numerical dollar amount does not match the dollar amount written in words.
givi [52]
Errrrrrrrrrrrr....... you can’t accept the cheque then, it’s wrong morally and legally. The cheque will bounce because you won’t accept it
8 0
4 years ago
Write a program that accepts a number as input, and prints just the decimal portion.
Olegator [25]

<u>Answer:</u>

<em>There are 2 ways to do extract the decimal part: </em>

<u>Explanation:</u>

  • <em>First method using number  </em>

<em>int main() { </em>

<em>  double num = 23.345; </em>

<em>  int intpart = (int)num; </em>

<em>  double decpart = num - intpart; </em>

<em>  printf(""Num = %f, intpart = %d, decpart = %f\n"", num, intpart, decpart); </em>

<em>} </em>

  • <em>Second method using string: </em>

<em>#include <stdlib.h> </em>

<em>int main() </em>

<em>{ </em>

<em>    char* inStr = ""123.4567"";          </em>

<em>    char* endptr;                       </em>

<em>    char* loc = strchr(inStr, '.'); </em>

<em>    long mantissa = strtod(loc+1, endptr); </em>

<em>    long whole = strtod(inStr, endptr);  </em>

<em>    printf(""whole: %d \n"", whole);      </em>

<em>    printf(""mantissa: %d"", mantissa);   </em>

<em>} </em>

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is an Important criterion for evaluating the effctiveness of a graphic organizer
    14·2 answers
  • An organization's contact information includes its _____.
    9·2 answers
  • It is vital to the organization and the success of the disaster recovery plan that the plan be thoroughly tested on a(n) _______
    5·1 answer
  • 2h2 + o2 → 2h2o<br> pls i need help
    10·1 answer
  • Because floating points have decimals, they're more precise and take up more memory than integers.
    6·1 answer
  • What type of filtering software divides email messages that have been received into two piles, spam and non-spam and then analyz
    13·1 answer
  • Write an algorithm to check whether the given number is divisible by 2,3 and 6 or not​​
    9·1 answer
  • Why is it important to prevent financial loss
    7·1 answer
  • What is the two’s compliment of -95,-122,-111,-57
    9·1 answer
  • QUESTION 9
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!