Find the errors and correct them – Provide the corrected code. using namespace s
ID: 3666482 • Letter: F
Question
Find the errors and correct them –
Provide the corrected code.
using namespace std;
void main( )
{
double number1, number2, sum;
Cout << “Enter a number: “;
Cin << number1;
Cout << “Enter another number: “;
Cin << number2;
number1 + number2 = sum;
Cout “The sum of the two numbers is “ << sum
}
Find the errors and correct them
#include <iostream>
using namespace std;
void main( )
{
char name, go;
cout << “Enter your name: “;
getline >> name;
cout << “Hi “ << name << endl;
}
Explanation / Answer
#include <iostream>
using namespace std;
int main( )
{
double number1, number2, sum;
cout << "Enter a number:";
cin >> number1;
cout << "Enter another number:";
cin >> number2;
sum=number1 + number2;
cout << "The sum of the two numbers is : " << sum << endl;
return 0;
}
Out Put:
Enter a number:12
Enter another number:12
The sum of the two numbers is : 24
#include <iostream>
using namespace std;
int main( )
{
string name;
cout << "Enter your name: ";
cin.ignore();
getline(cin, name);
cout << " Hi " << name << endl;
return 0;
}
Out Put:
Enter your name: naidu
Hi aidu
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.