Question
The following code consists of 5 parts. Find the errors for each part and fix them. Explain the errors using comments on top of each
The following code consists of 5 parts. Find the errors for each part and fix them. Explain the errors using comments on top of each part.
*/
#include
////////////////////////////////////////////////////////////////////////// ////////////// Part A. (5 points) //////////////////
int g(void) { printf("%s", Inside function g\ n " ); int h(void) { printf(" % s ", Inside function h\ n "); } }
printf("Part A: "); g(); printf(" ");
////////////////////////////////////////////////////////////////////////// ////////////// Part B. (5 points) //////////////////
int sum( int x, int y ) { int result; result = x + y; }
printf("Part B: % d ", sum(5,3));
////////////////////////////////////////////////////////////////////////// ////////////// Part C. (5 points) //////////////////
void f( float a ); { float a; printf( "%f", a ); }
printf("Part C: % 1f ", f(1.1));
////////////////////////////////////////////////////////////////////////// ////////////// Part D. (5 points) //////////////////
#include
int sum( int n ) { if ( 0 == n ) { return 0; } else { n + sum( n - 1 ); } }
printf("Part D: % d ", sum(3)); return 0; }
////////////////////////////////////////////////////////////////////////// ////////////// Part E. (5 points) //////////////////
void product( void ) { int a, b, c, result; printf( "%s", "Enter three integers: " ) scanf( "%d%d%d", &a, &b, &c ); result = a * b * c; printf( "Result is: %d", result ); return result; }
printf( "Part E: %d", product ());
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started