Question #307840

Identify the errors in the following programs, and explain how you would correct them to

make them do what they were apparently meant to do.

a). Give two ways to x this code: 2

#include <iostream >

int main()

{

printNum(35);

return 0;

}

void printNum( int number)

{

std::cout << number;

}


Expert's answer


int main()
{
	printNum(35);
	return 0;
}


void printNum( int number)
{
	std::cout << number;
}


/*
	The above code code will give an error as undeclared function printNum. 
	This is because the function was not declared above the main function.
*/


Correcetd Code:

using namespace std;


#include <iostream >
void printNum( int number)
{
	std::cout << number;
}


int main()
{
	printNum(35);
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS