QUESTION 8
What (if anything) will be the output of the following code:
int count = 3;
while (count++ <= 6)
{
System.out.print(++count + " ");
}
|
3 4 5 6 |
||
|
4 5 6 7 |
||
|
3 4 5 6 7 |
||
|
5 7 |
||
|
4 6 |
||
|
The above code contains a syntax error and will not run. |
8 points
QUESTION 9
What (if anything) will be the output of the following code:
int count = 0;
while (count < 5)
{
System.out.print(count++ + " ");
}
|
The above code contains a syntax error and will not run. |
||
|
0 1 2 3 |
||
|
1 2 3 4 5 |
||
|
0 1 2 3 4 |
||
|
0 0 0 0 0 |
||
|
1 2 3 4 |
8 points
QUESTION 10
What (if anything) will be the output of the following code:
int count = 0;
while (++count < 5)
{
System.out.print(count + " ");
}
|
0 1 2 3 |
||
|
1 2 3 4 5 |
||
|
The above code contains a syntax error and will not run. |
||
|
1 2 3 4 |
||
|
0 1 2 3 4 5 |
||
|
0 1 2 3 4 |
8 points
QUESTION 11
What (if anything) will be the output of the following code:
int count = 3;
while (count-- >= 0)
{
System.out.print(count + " ");
}
|
3 2 1 0 -1 |
||
|
3 2 1 0 |
||
|
2 1 0 |
||
|
The above code contains a syntax error and will not run. |
||
|
3 2 1 |
||
|
2 1 0 -1 |
QUESTION 8 the output of the given code 5 7 QUESTION 9 the output of the given code 0 1 2 3 4 QUESTION 10 the output of the given code 1 2 3 4 QUESTION 11 the output of the given code 2 1 0 -1
QUESTION 8 What (if anything) will be the output of the following code: int count =...
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...
QUESTION 6 What is the output of following C code? struct numbers { int x = 2; int y = 3; } int main() { struct numbers nums; nums.x = 110; nums.y = 100; printf("%d\n%d", nums.x, nums.y); return 0; } A. Compile-time Error B. 110 100 C. 2 3 D. Run-time Error 2 points QUESTION 7 What is the output of following C code? typedef struct student { char *stud; }s1; int main() { s1 s; s.stud...
QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p %p", *r, a); A. Different memory addresses printed B. 1 2 C. Same memory address printed twice D. 1 1 2 points QUESTION 10 What will be the output of following code snippet? int arr[4] = {1, 2, 3, 4}; int *p; p = arr + 3; *p = 5; printf("%d\n", arr[3]); A....
Thie What is the output of the following program segment? int count 1; do System.out.print(count (count-) + while(count++ <= 5);
What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...
QUESTION 10 What will be the output of following code snippet? char *str; str = "%s"; printf(str, "S"); A. S B. Garbage Value C. Compile-time Error D. Run-time Error 4 points QUESTION 11 What will be the output of the following statements assuming that the array begins at the memory address location 7002 and size of an integer is 4 bytes? int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%d,...
pic 4: Loops What is the output of the following code? int main0 ( int x = 1; while (x < 7) t İf ( (x % 2)-= 1)(1/ if x is odd x=x+1; else t x = x + 2; return 0; Select óne O a. 124 6 8 O b. 1 234 5 6 7 O c. 246 O d. 24 6 8 PREVIOUS PAGE NE
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
1. (TCO 1) What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++) cout << list[j]; (Points : 4) 0 1 2 3 4 0 5 10 15 0 5 10 15 20 5 10 15 20 Question 2.2. (TCO 1) What is stored in alpha after the following code executes? int alpha[5] = {0}; int j; for (j = 0; j...