Question 5: The following program transforms a string by converting lowercase letters to uppercase and replacing vowels with ‘#’. It also counts the times the letter ‘g’ appears in a string. Fill in the missing parts to complete the code logic. #include #include int gcounts(char str[]) { int count=0; // Question e) use strlen to scan the string and count the number of times ‘G’ appears return count;} void encode(char str[]) { char *p = str; // Question a) while ( ___________ ) { // Question b) if (*p >= ‘a’ && *p max_g) { max_g = g_count; max_index = i; } } if (max_index != -1) { printf(“\nString with the most ‘g’s: %s\n”, courses[max_index]); printf(“Index: %d, ‘g’ count: %d\n”, max_index, max_g); } return 0; } b) Finish the while loop stopping condition, see if anything else is missing to ensure the loop works correctly.
Blog
Question 5: The following program transforms a string by con…
Question 5: The following program transforms a string by converting lowercase letters to uppercase and replacing vowels with ‘#’. It also counts the times the letter ‘g’ appears in a string. Fill in the missing parts to complete the code logic. #include #include int gcounts(char str[]) { int count=0; // Question e) use strlen to scan the string and count the number of times ‘G’ appears return count;} void encode(char str[]) { char *p = str; // Question a) while ( ___________ ) { // Question b) if (*p >= ‘a’ && *p max_g) { max_g = g_count; max_index = i; } } if (max_index != -1) { printf(“\nString with the most ‘g’s: %s\n”, courses[max_index]); printf(“Index: %d, ‘g’ count: %d\n”, max_index, max_g); } return 0; } e) In gcount(), use strlen() to scan the string and count how many ‘g’ characters it contains
Question 2: Trace and determine the output of the following…
Question 2: Trace and determine the output of the following program. Justify your answer by explaining the code with comments. #include int main() { int x, y, z, w, v; int *p1, *p2; p1 = &x; *p1 = 2; p2 = &y; *p2 = *p1 * 3; //Add your comment: p1 = &z; //Add your comment: *p1 = *p2 – *(&x); //Add your comment: p2 = &w; //Add your comment: *p2 = *(&z) + *(&y); //Add your comment: p1 = &v; //Add your comment: *p1 = *(&w) – *(&z) + *(&x); //Add your comment: printf(“%d %d %d %d %d\n”, x, y, z, w, v); return 0; }
Software security is a:
Software security is a:
Which of the following is NOT the best practice to list all…
Which of the following is NOT the best practice to list all books written by the author with ID 7?
Black box testing:
Black box testing:
Which statement accurately distinguishes between verificatio…
Which statement accurately distinguishes between verification and validation processes in software engineering?
Which scenario would best require the use of a sequence diag…
Which scenario would best require the use of a sequence diagram?
What kind of relationship between classes does the following…
What kind of relationship between classes does the following symbol represent in UML Class Diagrams:
Which of the following is NOT true about regression testing:
Which of the following is NOT true about regression testing: