3. (15 pts) Complete the code below to print the second to last character of the
ID: 3708951 • Letter: 3
Question
3. (15 pts) Complete the code below to print the second to last character of the string mystring. char mystring[200; scanf("%s", mystring); /* initialize from standard input */ (10 pts) Declare (not define) a function called longer that takes two strings as parameters (without using array notation) and returns the longer string. 4. 5. (15 pts) Fix the error in the following fragment. Explain why. void makeAvailable(char *p) strcpy(p, "Available": char status "Unavailable" char value; printf"Should make available? y/n: "; scanf("%c", &value;); if (valueY) makeAvailable(status); 6. (25 pts) Write a function removeSpaces that remove all space characters from a given string s1 and stores the result in a second string s2. Your function should have the following prototype: void removeSpaces (char *s1, char 's2)Explanation / Answer
If you have any doubts, please give me comment...
3)
char mystring[200];
scanf("%s", mystring);
printf(" %s ", mystring+2);
4)
char *longer(char *str1, char *str2){
int len1 = strlen(str1), len2 = strlen(str2);
if(len1<len2)
return str2;
else
return str1;
}
5)
void makeAvailable(char *p){
strcpy(p, "Available");
}
char status[] = "Unavailable";
char value;
printf("Should make available? y/n: ");
scanf("%c", &value);
if(value=='y')
makeAvailable(status);
6)
void removeSpaces(char *s1, char *s2){
int i=0, j=0;
while(s1[i]!=''){
if(s1[i]!=' '){
s2[j] = s1[i];
j++;
}
i++;
}
s2[j] = '';
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.