View the step-by-step solution to:

Question

Hi guy

im studying for my exam in c programming, and I was wondering of someone can look over my answer and

see if I got it correct. I place my answer in bold fonts.



Question 21


Follow the code below to completion. At the end, what value is contained within the variable x?

int myArray[5] = {10, 20, 30, 40, 50};

int i;

for(i = 0; i < 5; i++)

  myArray[i] += i;

int x = myArray[4];




44


11


43


54


22


21


10


32


55


33

 


Question 22


main(){

   int array[10][5] = {0};

   int i, j, sum = 0;

   for(i = 0; i < 5; i++)

     for(j = 0; j < 5; j++)

        array[i][j] = i + j;


   for(i = 0; i < 10; i++)

       for(j = 0; j < 5; j++)

          sum += array[i][j];


// What is the value of sum here

     printf("The value of sum is %i.n", sum);

} // end main




0


105


110


no way of knowing


95


100


50

 


Question 23


Using pseudocode, pseudo-C, or C, write code below that does the following:

SUMMATION: Continuously prompt the user for integer input. Add the value entered to a growing sum. Stop prompting for input when the user enters -1. Do not add the -1 to the total.

HTML Editor

Keyboard Shortcuts





 


Question 24


1] main(){

2]   int myArray[5] = {10, 20, 30, 40, 50};

3]   int i;

4]   for(i = 0; i < 5; i++)

5]   myArray[i] += i;

6]  int x = myArray[4];

7]  printf("%in", x);

8]}// end main




line 8 is a C statement


Line 3 sets the value of i to zero


line 2 has a syntax error


Line 5 changes the value of the array

 


Question 25


1] main(){

2]   int myArray[5] = {10, 20, 30, 40, 50}:

3]   int i;

4]   for(i = 0; i < 5; i++)

5]   myArray[i] += i;

6]  int x = myArray[4];

7]  printf("%in", x);

8]}// end main

 

// Which of the above 8 lines has an error




5


2


7


6


1


8


4


3

 


Question 26


int myArray[5][5] = {0,0};

int i, j;

for(i = 0; i < 5; i++)

  for(j = 0; j < 5; j++)

     myArray[i][j] += j;

 

// Assume above and below the above code is valid code

// what would the contents of the array look like




No Elements would contain 0


All the Values in any Column would be the same


All Elements would contain 0


All the Values in any Column would be different

 


Question 27


int myArray[5][5] = {0,0};

int i, j;

for(i = 0; i < 5; i++)

  for(j = 0; j < 5; j++)

    myArray[i][j] = 1;

 

// What is the total of all the values within the array




0


25


Above 100


No way of knowing


1


Below 25


Above 25


Question 28


void changeIt(int *x, int y){

   *x = *x;

   y++;

}

 

main(){

  int x = 5;

  int y = x;

  changeIt(&x, y);

} // what would be the value of x + y HERE




5


Now way of knowing


10


25

 


Question 29


Using Pseudo Code or C code or somewhat C code, make a function that receives a previously populated array. The function will put the elements of the array in order from High to Low.

HTML Editor

Keyboard Shortcuts

Top Answer

Question 21 Follow the code below to completion. At the end, what value is contained within the variable x? int myArray[5] =... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question