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

In C Programe. multiple choice questions. Please answer with explain. Thank you

ID: 3735232 • Letter: I

Question

In C Programe. multiple choice questions.

Please answer with explain. Thank you so much

Multiple Choice (4 pts. each) For problems 21 through 35 use the following code for Consider the following program for problems 29-31 your numeric answers A-0 B- C-2 D-3 E- AC-6 AD-7 AE-8 BC-9 BD 10 BE 11 CD- 12 CE- 13 DE 14 ABCDE none of these Use the following program for problems 21-22 # include int main # include 4 AB 5 int Eunci (int vaii, int val2) t int tmp va12; val2-vall; return val2 valli main)I int val2 10; int vall 5 int va13 Eunel (&val2;, va11) printf( "vall %d va12 %d va13 %d ". int n: Eor n12: n>-5 n++) printf ("%d, ", n); vall, val2, va13) return 0 21. How many iterations of the loop occur? 22. What is the last value printed out? return 0h 29. What is vall after the call to func1? 30. What is val2 after the call to func1? 31. What is val3 after the call to func1? Consider the following code snippet for problems 23-25 Use the following code and input for problems 32-33 int i,j int numrows, numcols; int ourGrid 101 1101 int i int a[7] (5, 12, 4, 0, 1, 7, 2); if (a[i-1] > a[i]) { &numeols;); scanf ("%ded ", &numrows;, for-0;i

Explanation / Answer

21:

Correct option: D-3

Explanation:

There will be 3 iterations. First the value of n = 12; At 1st iteration the loop will execute and end of loop the value of n will be 12-4 = 8, and then n will be n++ so n will become 9; So then n>=5 will be satisfied and 2nd iteration will be there; at 2nd iteration the loop will execute and at the end of loop the value of n will be 9-4 = 5, and then n will be n++ so n will become 6; So then n>=5 will be satisfied and 3rd iteration will be there; at 3rd iteration the loop will execute and at the end of loop the value of n will be 6-4 = 2, and then n will be n++ so n will become 3; So then n>=5 will not be satisfied;

Hence there will be 3 iterations of the given loop.

22:

Correct option: AC - 6

Explanation:

There will be 3 iterations. First the value of n = 12; At 1st iteration the loop will execute and 12 is printed at screen; and end of loop the value of n will be 12-4 = 8, and then n will be n++ so n will become 9; So then n>=5 will be satisfied and 2nd iteration will be there; at 2nd iteration the loop will execute and 9 will be printed on screen; at the end of loop the value of n will be 9-4 = 5, and then n will be n++ so n will become 6; So then n>=5 will be satisfied and 3rd iteration will be there; at 3rd iteration the loop will execute and 6 will be printed on screen; at the end of loop the value of n will be 6-4 = 2, and then n will be n++ so n will become 3; So then n>=5 will not be satisfied;

Hence there will be 3 iterations of the given loop, at the end of loop execution the last value that will be printed on screen: 6

23:

Correct option: CD - 12

Explanation:

Given code:

int a[7] = {5,12,4,0,1,7,2};

               for(i=1;i<6;i++){

                              if(a[i-1]>a[i])

                              {

                                             a[i]=a[i-1];

                                             a[i-1]=a[i];

                              }

               }

This loop will execute 5 times. At first iteration i=1, so a[0] and a[1] is compared as a[0] is less than a[1] so if block will not be executed;so value of a[0] and a[1] remain unchanged here.

At 2nd iteration i=2, so a[1] and a[2] is compared as a[1] is greater than a[2] so if block will be executed;so value of a[1] and a[2] will be same after this iteration and it will be 12 here;

At 3rd iteration i=3, so a[2] and a[3] is compared as a[2] is now 12 and a[3] is 0 so a[2] is greater than a[3] so if block will be executed;so value of a[2] and a[3] will be same after this iteration and it will be 12 here;

At 4th iteration i=4, so a[3] and a[4] is compared as a[3] is now 12 and a[4] is 1 so a[3] is greater than a[4] so if block will be executed;so value of a[3] and a[4] will be same after this iteration and it will be 12 here;

At 5th iteration i=5, so a[4] and a[5] is compared as a[4] is now 12 and a[5] is 7 so a[4] is greater than a[5] so if block will be executed;so value of a[4] and a[5] will be same after this iteration and it will be 12 here;

Hence after execution of given code the value of a[2] will be 12 ;

24:

Correct option: CD - 12

Explanation:

Given code:

int a[7] = {5,12,4,0,1,7,2};

               for(i=1;i<6;i++){

                              if(a[i-1]>a[i])

                              {

                                             a[i]=a[i-1];

                                             a[i-1]=a[i];

                              }

               }

This loop will execute 5 times. At first iteration i=1, so a[0] and a[1] is compared as a[0] is less than a[1] so if block will not be executed;so value of a[0] and a[1] remain unchanged here.

At 2nd iteration i=2, so a[1] and a[2] is compared as a[1] is greater than a[2] so if block will be executed;so value of a[1] and a[2] will be same after this iteration and it will be 12 here;

At 3rd iteration i=3, so a[2] and a[3] is compared as a[2] is now 12 and a[3] is 0 so a[2] is greater than a[3] so if block will be executed;so value of a[2] and a[3] will be same after this iteration and it will be 12 here;

At 4th iteration i=4, so a[3] and a[4] is compared as a[3] is now 12 and a[4] is 1 so a[3] is greater than a[4] so if block will be executed;so value of a[3] and a[4] will be same after this iteration and it will be 12 here;

At 5th iteration i=5, so a[4] and a[5] is compared as a[4] is now 12 and a[5] is 7 so a[4] is greater than a[5] so if block will be executed;so value of a[4] and a[5] will be same after this iteration and it will be 12 here;

Hence after execution of given code the value of a[1] will be 12 ;

25:

Correct option: AB - 5

Explanation:

Given code:

int a[7] = {5,12,4,0,1,7,2};

               for(i=1;i<6;i++){

                              if(a[i-1]>a[i])

                              {

                                             a[i]=a[i-1];

                                             a[i-1]=a[i];

                              }

               }

This loop will execute 5 times. At first iteration i=1, so a[0] and a[1] is compared as a[0] is less than a[1] so if block will not be executed;so value of a[0] and a[1] remain unchanged here.

At 2nd iteration i=2, so a[1] and a[2] is compared as a[1] is greater than a[2] so if block will be executed;so value of a[1] and a[2] will be same after this iteration and it will be 12 here;

At 3rd iteration i=3, so a[2] and a[3] is compared as a[2] is now 12 and a[3] is 0 so a[2] is greater than a[3] so if block will be executed;so value of a[2] and a[3] will be same after this iteration and it will be 12 here;

At 4th iteration i=4, so a[3] and a[4] is compared as a[3] is now 12 and a[4] is 1 so a[3] is greater than a[4] so if block will be executed;so value of a[3] and a[4] will be same after this iteration and it will be 12 here;

At 5th iteration i=5, so a[4] and a[5] is compared as a[4] is now 12 and a[5] is 7 so a[4] is greater than a[5] so if block will be executed;so value of a[4] and a[5] will be same after this iteration and it will be 12 here;

Hence after execution of given code the value of a[0] will be 5 .

/*As per Chegg guidelines, if a question of the user contains more than one sub-questions then the expert is supposed to answer first four questions. Though I have answered 5 here. There is time constraint for experts to answer a question. Hope you understand. :) . Please repost the rest of questions to get the answers.*/

/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/