Upload link 1 // debug this program #include <stdio.h> int ( void ) { Int i // l
ID: 3913974 • Letter: U
Question
Upload link 1
// debug this program
#include <stdio.h>
int ( void )
{
Int i // loop counter
int x // first integer from user
int y // second integer from user
// loop four times
for ( i = 1; i <= 4; ++i ) {
printf( "%s", " Enter two integers spearated by a space: " );
sanf( "%i%d", &x, y );
printf( "%d %d ", x, y );
} // end for
} // end main
Upload link 2
Complete and debug this progarm
// print the integer 12345
printf( "%10 ", 12345 );
printf( "%5d ", 12345 );
printf( "%2d ", 12345 );
// print the floating-point value 1.2345
printf( "%10 ", 1.2345 );
printf( "%6f ", 1.2345 );
printf( "%2f ", 1.2345 );
Explanation / Answer
Answe 1: See all comments enclosed in /* -- */
#include <stdio.h>
int main( void ) /* main keyword was missing */
{
/* semicolon is missing in each declaration and Int i should be int i*/
int i; // loop counter
int x; // first integer from user
int y; // second integer from user
// loop four times
for ( i = 1; i <= 4; ++i ) {
printf( "%s", " Enter two integers spearated by a space: " );
/*function should be scanf not sanf, we are reading input from user so use &y */
scanf( "%i%d", &x, &y );
printf( "%d %d ", x, y );
} // end for
/* add return 0 */
return 0;
} // end main
----------------------------------------------------------------------------
Answer 2: See comments enclosed in /* -- */
#include <stdio.h>
int main()
{
// print the integer 12345
/*printf( "%10 ", 12345 ); //this can't be used because it don't have format specifier */
printf( "%5d ", 12345 );
printf( "%2d ", 12345 );
// print the floating-point value 1.2345
/*printf( "%10 ", 1.2345 ); //this can't be used because it don't have format specifier */
printf( "%6f ", 1.2345 );
printf( "%2f ", 1.2345 );
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.