5 Find all the errors in the following program include usin

(5) Find all the errors in the following program. #include ;

using namespace std;

void main()

{

double number, half;

cout<< “Enter a number and I will divide it\ ”

cout<< “in half for you.\ ”

cin>> numbr1;

half=/2;

}

Solution

Please find the errors in the given program below with its description :

i) void main() : main function must return int. It should be like : int main()

ii) cout<< “Enter a number and I will divide it\ ” : semi colon is missing at the end of the statement

iii) cout<< “in half for you.\ ” : semi colon is missing at the end of the statement

iv) cin>> numbr1; numbr1 is not declared in the scope. It should be number(as per the variable declaration given above)

v) half =/ 2; invalid expression, it should be : half /= 2 (which means half = half / 2)

(5) Find all the errors in the following program. #include ; using namespace std; void main() { double number, half; cout<< “Enter a number and I will div

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site