Question 7: This program manages Pet Adoption Records. Each…

Question 7: This program manages Pet Adoption Records. Each Pet has a name, species, and a Date of adoption, and is linked to an Adopter who has a name and age.  Complete the code below by filling in the missing parts   #include typedef struct {     // Question a) Define Adopter struct with name and age } Adopter; typedef struct { // Question b) Define a Date struct with day, month, and year } Date; typedef struct { // Question c) Define Pet struct with name, species, Date of adoption, and Adopter } Pet; // Question c) Function to print one Pet’s info void PrintPet_info(______________________) { } int main(){     Pet pets[3] = {     { “Bella”, “Dog”, {15, 3, 2023},   {“Emily Johnson”, 27}  },     { “Milo”, “Cat”, {22, 7, 2022}, {“Michael Smith”, 34} },     {“Luna”, “Rabbit”, {3, 1, 2024}, {“Jessica Miller”, 19} } };     // Question d) Print info for all pets using  PrintPet_info function     return 0;}    d) Write a function called printPet() that takes a Pet as an argument (passed by value) prints all the fields: name, species, adopter name/age, and date of adoption in dd/mm/yyyy format

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; } c) Write conditional statement(s) to replace vowels in string with ‘#’. 

1. Solve the questions for the following c code,  #include v…

1. Solve the questions for the following c code,  #include void fun1(int x, int *y){    x = x * (*y);    *y = 3 * (*y); } int main(){    int x = 3, y =7 ;    fun1(x, y); if(x==y){               printf(“x=y=%d”, x); }else{               printf(“%d\t%d\n”, x, y); }    return (0);} b) What will be printed when the corrected program is compiled and executed? and why?

Question 6: Consider the following C program with two functi…

Question 6: Consider the following C program with two functions: Search() and Sort(), answer the following questions assuming no syntax error:  int Search(int arr[], int size, int key) {     int low = 0, high = size – 1, iterations = 0;     while (low arr[j + 1]) {                 arr[j] = arr[j + 1];                 arr[j + 1] = arr[j];                 swapCount++;             }         }     }     return swapCount; } int main() {     int nums[7] = {19, 2, 73, 10, 25, 46, 100};     int key = 25, SIZE=7;     int X1= Search(nums, SIZE, key);       printf(“result: %d\n”,X1); //Print 1     int Y = Sort(nums, SIZE);     printf(“\nTotal swaps: %d\n”, Y); //Print 2     int X2= Search(nums, SIZE, key);      printf(“result: %d\n”,X2); //Print 3     return 0;} c) What will be the output printed by this code? and why? Explain every print line (You may assume the code compiles and runs.)

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; } b) Finish the while loop stopping condition, see if anything else is missing to ensure the loop works correctly. 

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; }