Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What does this program do? /* ex07_22.c */ /* what does this program do? */ #inc

ID: 3622192 • Letter: W

Question

What does this program do?

/* ex07_22.c */
/* what does this program do? */
#include <stdio.h>

int mystery2( const char *s ); /* prototype */

int main( void )
{
char string[ 80 ]; /* create char array */
printf( "Enter a string: ");
scanf( "%s", string );
printf( "%d ", mystery2( string ) );
return 0; /* indicates successful termination */

} /* end main */

/* What does this function do? */
int mystery2( const char *s )
{
int x; /* counter */
/* loop through string */
for ( x = 0; *s != ''; s++ )
{
x++;
} /* end for */
return x;
} /* end function mystery2 */

Explanation / Answer

please rate - thanks

counts and outputs how many characters are in the input string

/* ex07_22.c */
/* what does this program do? */
#include <stdio.h>

int mystery2( const char *s ); /* prototype */

int main( void )
{
char string[ 80 ]; /* create char array */
printf( "Enter a string: ");
scanf( "%s", string );
printf( "%d ", mystery2( string ) );
return 0; /* indicates successful termination */

} /* end main */

/* What does this function do? */
int mystery2( const char *s )
{
int x; /* counter */
/* loop through string */
for ( x = 0; *s != ''; s++ )          //x is the counter starts at 0
{                                                //start at 1st element of the input string, and do until you get to the
x++;                                         //null which indicated the end of the array, incrementing x each time
} /* end for */                          //through the loop
return x;
} /* end function mystery2 */

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote