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

NO string.h library 1. Implement the reverseWord function such that it reverses

ID: 3528982 • Letter: N

Question

NO string.h library 1. Implement the reverseWord function such that it reverses all the characters in the word. #include /* You may NOT call any other string functions. * Do NOT include string.h. * Do NOT alter main in any way. */ void reverseWord(char w[]); int main () { char word[10]; printf("Word: "); scanf("%s", word); reverseWord(word); printf("Reversed: %s ", word); return 0; } void reverseWord(char w[]) { /* Write code here */ } 2. Implement the hasSubstring function such that it returns true if the input word contains the given substring and returns false otherwise.#include /* You may NOT call any other string functions. * Do NOT include string.h. * Do NOT alter main in any way. */ int hasSubstring(char w[], char sub[]); int main () { char word[10], substring[10]; printf("Word: "); scanf("%s", word); printf("Substring to search for: "); scanf("%s", substring); if (hasSubstring(word, substring)) { printf("%s contains the substring %s. ", word, substring); } else { printf("%s does NOT contain the substring %s. ", word, substring); } return 0; } int hasSubstring(char w[], char sub[]) { /* Write code here */ }

Explanation / Answer

#includeint main(){ char str[50]; char rev[50]; int i=-1,j=0; printf("Enter any string : "); scanf("%s",str); while(str[++i]!=''); while(i>=0) rev[j++] = str[--i]; rev[j]=''; printf("Reverse of string is : %s",rev); return 0; }