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

1. What is the output ofthe following code: (3pts) char findit(char str) char p

ID: 3817239 • Letter: 1

Question

1. What is the output ofthe following code: (3pts) char findit(char str) char p str; char t str strlen(str)-1 while (p k t) return p; char data[] Which one is it?"; char p findit (data); printf("%c", *p); strcpy (data, "12345"); printf ("%c", *p); 2. Write the statements to read two strings from user input and output the one that comes later in lexicographic order (1 pt 3. Complete the code below to print the second to last character of a string. (2 pts) char mystring[2001; scan ("%s", mystring); //i nitialize from standard input 4. Write the prototype of a function that takes two strings as parameters (without using array notation) and returns the longer string. 1 pt)

Explanation / Answer

1.) The given code will print "ee" because findit() function return the address from the character where 'e' is located.

3.) The last two lines will be sufficient to get the required functionality:

char mystring[200];

scanf("%s", mystring);

l = strlen(mystring);

printf("%c", mystring[l-2]);

4.) char *largerString( char *str1, char*str2);

5.) The following code gives the error-free compiled code:

#include<stdio.h>
#include<string.h>

void makeAvailable(char *p)
{
strcpy(p,"Available");
}

int main()
{
char *status = "Unavailable";
char value;
printf("Should make available? y/n");
scanf("%c",&value);
if(value == 'y')
makeAvailable(&status);
//printf("%s",status);
return 0;
}//end of main function