Syntaxx and code form is not a problem in any of the problems here. Spaces b/w words dont matter nor does indentation. Try again!
soer
Posts
-
Test your C++ knowledge with these questions! -
Test your C++ knowledge with these questions!Hi, I just came up with some quick C++ problems that I thought some people might like to try out. Post your answers as replies. Good luck! 1) Identify any errors in the following declarations. a. int x[4] = { 8,7,6,4,3 }; b. int x[] = { 8,7,6,4 }; c. const int SIZE = 4; int x[SIZE]; 2) What is wrong with the following piece of code? int sample_array[10]; for (int index=1; index<=10; index++) sample_array[index] = 3*index; 3) Suppose we expect the elements of the array a to be ordered so that a[0] <= a[1] <= a[2] <=… However, to be safe we want our program to test the array and issue a warning in case it turns out that some elements are out of order. The following code is supposed to output such a warning, but it contains a bug. What is it? double a[10]; for (int index = 0; index <10; index++) if(a[index] > a[index +1]) cout <<”Array elements”<