Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <iostream> #include <iomanip> using namespace std; int main() { bool re

ID: 638333 • Letter: #

Question

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

      bool response = 234;

      char character = 68;

      int integer = 123.456789;

      float single_precision_number = 1234.567890123456789;

      double double_precision_number = 1234.567890123456789;

      cout<<"response = "<< response <<endl;

      cout<<"character = "<< character <<endl;

      cout<<"integer = "<< integer <<endl;

      cout<<"single_precision_number = "<< setprecision (17)

<<single_precision_number<<endl;

      cout<<"double_precision_number = "<< setprecision (17)

<<double_precision_number<<endl;

      return 0;

}

Question 1:Please explain each line of output.

Question 2:Make the following changes to the program in Step 2 (simpleTypeDecls2.cpp) and

explain the output you get.

change the value of

Explanation / Answer

Question 1: Answer
================================================================================

#include <iostream>
//iostream is a header file contaians input/ouptut functions like cin and cout
#include <iomanip>
//iomanip is a header file cotaines setprecision and setw used for formatting
//output

using namespace std;

int main()
{

bool response = 234;
//response is boolean type as we are assigning positive value (>0) the
//value of variable is 1 , anb
for (<=0) value of variable is 0

char character = 68;
//character is char type with input value 68
//Means take the character associated with ASCII value
//ASCII values are A - 65 ,B -66, C -67,D-68
int integer = 123.456789;
//integer is int type, thogh we are assigning float value
//It wont consider decimnal part and hecne value is 123
float single_precision_number = 1234.567890123456789;
//single_precision_number is float type
//Hence the value will be stored upto 11 precisions
double double_precision_number = 1234.567890123456789;
//single_precision_number is float type
//Hence the value will be stored upto any precisions
  

cout<<"response = "<< response <<endl;
//response = 1
cout<<"character = "<< character <<endl;
//character = D
cout<<"integer = "<< integer <<endl;
//integer = 123
cout<<"single_precision_number = "<< setprecision (17)

<<single_precision_number<<endl;
//single_precision_number = 1234.56787109375
cout<<"double_precision_number = "<< setprecision (17)

<<double_precision_number<<endl;

//double_precision_number = 1234.5678901234569

return 0;
//Program completed

}


output is:
------------------------

response = 1
character = D   
integer = 123   
single_precision_number = 1234.56787109375
double_precision_number = 1234.5678901234569   
================================================================================
Question2:

bool response = 0;
char character = 'A';

output is:
------------------------

response = 0
character = A   
integer = 123   
single_precision_number = 1234.56787109375
double_precision_number = 1234.5678901234569