Respuesta :
Answer:
Corrected statements:
cout<<"Foretelling is hard."<<endl;
cout << "Particularly";
cout << "of the future." << endl;
cout << "User num is: " << userNum << endl;
Explanation:
- Statement 1: cout << "Foretelling is hard." <<end;
Syntax Error generated when the statement is compiled: no match for ‘operator<<’ (operand types are ‘std::basic_ostream’ and ‘’)
This error is generated because "end" is used which is not valid. It should be replaced with endl which is used to insert a new line.
So the corrected statement without syntax error is:
cout << "Foretelling is hard." <<endl;
The output of this corrected line is as following:
Foretelling is hard.
- Statement 2: cout << "Particularly ';
Syntax Error generated when the statement is compiled: missing terminating " character
This error is generated because the one of the double quotations is missing in the statement and single quote is used instead which resulted in syntax error. So in order to correct this syntax error single quote ' should be replaced with double quotation mark ".
So the corrected statement without syntax error is:
cout << "Particularly";
The output of this corrected line is as following:
Particularly
- Statement 3: cout << "of the future." << endl.
Syntax Error generated when the statement is compiled:
‘std::endl’ does not have class type
This error is produced because the statement did not end in semicolon. Instead it is ended with a period (.) placed after endl
So in order to remove this syntax error ; is placed instead of .
So the corrected statement without syntax error is:
cout << "of the future." << endl;
The output of this corrected line is as following:
of the future
- Statement 4: "User num is: " << userNum >> endl;
Syntax Error generated when the statement is compiled:
no match for ‘operator>>’ (operand types are ‘std::basic_ostream’ and ‘’)
This error is produced because extraction operator >> is being used instead of insertion operator << . Here the value of userNum is to be displayed and next line is to be inserted so insertion operator << should be used in place of extraction operator which is used for input.
So the corrected statement without syntax error is:
cout << "User num is: " << userNum << endl;
Now lets declare the variable userNum and assign it value 5 as:
int userNum = 5;
So output of this corrected line is as following:
User num is: 5
If tested for userNum=11 then the output is as following:
User num is: 11