


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The correction of programming errors in c++ for various functions such as square and maximum. Each question includes the incorrect code, the corrected code, and the explanation of the error.
Typology: Lecture notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Please find the program errors and correct them. Question 1
using std::cout; int square ( int); int main ( ) { for ( int x =1; x <=10; x++) cout << square(x) << โ โ; return(0); } void square( int y) { return y*y; } Question 2 int maximum ( int, int, int); //function prototype โฆ.. cout << maximum (a, b, c); // calling function โฆโฆ int maximum (int x, y, z) // function definition { int max =x; if (y> max) max =y; if (z > max) max = z; return max } Question 3
int square ( int); int main ( ) { for ( int x =1; x <=10; x++) cout << square(x) << โ โ; return(0); } int square( int y); { return y*y; } Question 4
using std::cout; int square ( int); int main ( ) { for ( int x =1; x <=10; x++) cout << square(x) << โ โ; return(0); } int square( int y) { int y; return y*y; } Question 5
int square ( float); int main ( ) { for ( int x =1; x <=10; x++) cout << square(x) << โ โ; return(0); } int square( int y) { return y*y; } Question 8
using std::cout; int square ( int) int main ( ) { for ( int x =1; x <=10; x++) cout << square(x) << โ โ; return(0); } int square( int y) { return y*y; }