What does this program show on the screen What does this pro

What does this program show on the screen? What does this program Show on the screen? There are multiple error in the following program. Describe each error and how it can be fixed. What does this program show on the screen?

Solution

-------------------------------------------Program 1------------------------------------------------

#include<iostream> // include header file
int main() // main function with a return value of int type
{
std::cout<< \"Is there \"<< 4 +5; // This steps print the output of (4 + 5)
std::cout<< \" continents\"<< std::endl; // print continents and std::endl is for nextline
return 0; // return value is int type so that we return 0
}

//-------------------Output--------------------------
Is there 9 continents

-------------------------------------------Program 2------------------------------------------------

// Here comes the operator priority Brackets, Multiplication/Division, Addition/Subtraction
#include<iostream>
int main() // main function with a return value of int type
{
std::cout<< 2 + 4 * 2 + 3<<std::endl; // This steps print the output of (4 * 2) = 8 + 2 + 3 = 11
int y=4 - 6 /2; // y is assigned as 4 - (6 /2) = 4 -3 =1 because Multiplication has higher priority than subtraction
std::cout<<\"y = \" << y << std::endl; // print the value of y
return 0; // return value is int type so that we return 0
}

//-------------------Output--------------------------
13

y=1

-------------------------------------------Program 3-----------------------------------------------------------------------------

1. #include<iostream>
2. int main() // main function with a return value of int type
3. {
4. std::cout<<\"Hello Houston!
5. return \"program ends\"; // return value is int type so that we return 0
6. }

First Error is in line no 4 Error : Missing termination Characters Solution is std::cout<<\"Hello Houston! \";

Second error is in line 5 because return type is integer and we are returning char * so the error is: invalid conversion from \'const char*\' to \'int\' and the solution is that the main can return an integer value. so convert return into integer value return 0;

So the correct program is

#include<iostream>
int main() // main function with a return value of int type
{
std::cout<<\"Hello Houston!\";
return 0; // return value is int type so that we return 0
}

-------------------------------------------Program 4-----------------------------------------------------------------------------

// Here comes the operator priority Brackets, Multiplication/Division, Addition/Subtraction
#include<iostream>
int main() // main function with a return value of int type
{
int x=10; //define integer variable x with initial value of 10
double y=2.3;//define double variable y with initial value of 2.3
std::cout<< x <<\" x \"<< y <<\" = \" << x * y <<std::endl; // print x value y value and x multiplication with y
return 0; // return value is int type so that we return 0
}

//-------------------Output--------------------------

10 x 2.3 = 23

 What does this program show on the screen? What does this program Show on the screen? There are multiple error in the following program. Describe each error an
 What does this program show on the screen? What does this program Show on the screen? There are multiple error in the following program. Describe each error an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site