| |

Question: 14.5 Lab 2a – Output Formatting (1) Declare 3 doubles (2) Read in 3 values (3) Write out the result to 1 decimal place of summing the three variable values and dividing the sum by 10. LAB ACTIVITY 11.5.1: Lab 2a – Output Formatting 0/4 main.cpp 1 – Free Chegg Question Answer

Please help me with the answer for this question. I need the code format.

Transcribed text From Image: 14.5 Lab 2a - Output Formatting (1) Declare 3 doubles (2) Read in 3 values (3) Write out the result to 1 decimal place of summing the three variable values and dividing the sum by 10. LAB ACTIVITY 11.5.1: Lab 2a - Output Formatting 0/4 main.cpp 1

Expert Chegg Question Answer:

free chegg question answer
Smart Teacher From Answerie.com
Answer:

Answer


To print a floating point number with 1 decimal place use %.1f in printf statement.

For 2 decimal place use %.2f and so on.

Program:

#include <iostream>

using namespace std;

int main()

{
    
    // declare 3 doubles veriables 
    double a, b, c;
    
    cout << "Enter 3 numbers";
    
    // read in 3 values
    cin >> a >> b >> c;
    
    // write out result to 1 decimal place of summing the 3 veriables and divide the sum by 10
    printf("%.1f", (a + b + c)/10); 
    
    return 0;
}

Screenshot:

  • main.cpp ******** 2 3 Online C++ Compiler. 4 Code, compile, Run and Debug C++ program online. 5 Write your code in this edito

Free Chegg Question Answer

Leave a Reply

Your email address will not be published. Required fields are marked *