Answer to Question #307840 in C++ for Bhanu

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;

}


1
Expert's answer
2022-03-08T07:12:38-0500


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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog