Question

Consider the following segment of C-code: int j, n; j = 1; while (j <= n)...

Consider the following segment of C-code:

 int j, n;
  j = 1;
  while (j <= n)
        j = j*2; 


Group of answer choices

FLOOR(logn) + 2

CEIL(logn)

n

CEIL(logn) + 2

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Option 1

Answer:

FLOOR(logn) + 2

Add a comment
Know the answer?
Add Answer to:
Consider the following segment of C-code: int j, n; j = 1; while (j <= n)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for...

    Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for (int j = 0; j <m; ++j) if (i != j) cout << "0"; else cout << "1"; } } Which of the options below gives the correct output if the value of nis 2and the value of mis 3? 1. 100010 2. 011101 3. 100100 4. 010001

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

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

  • Consider the following code segment: int[][] mystery = new int[3][3]; int counter = 0; while(counter <...

    Consider the following code segment: int[][] mystery = new int[3][3]; int counter = 0; while(counter < mystery.length) { for(int col = 0; col < mystery[counter].length; col++) { if(counter == 0) { mystery[col][counter] = 1; } else if(counter == 1) { mystery[counter][col] = 2; } else { mystery[counter][counter] = 3; } } counter++; } What will the value of each element in mystery be after the execution of the code segment? a) {{1, 0, 0} {2, 2, 2} {1, 0, 3}}...

  • 18 C++ 1. What is the output of the following program segment? int y-22: while ((y...

    18 C++ 1. What is the output of the following program segment? int y-22: while ((y 3) != 0) cout << y<< "": y=y-2; The output is 2. Suppose that the input is 100, 20,-8, 50, 20. What is the output of the following C++ code? int sum0 int num: int j cin >> num: if (num < 0) continue зит зит + num; cout<< sum << endl; The output is

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    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...

  • Consider the following C++ code segment: if (i j) cout << "1"; else if ((i &j)...

    Consider the following C++ code segment: if (i j) cout << "1"; else if ((i &j) < 3) cout << "2"; else if (i < (j-1)) cout << "3"; else cout << "4"; cout << "5"; If the value of iis 5and the value of jis 6, which of the options below gives the correct output? 1. 25 2. 35 3. 15 4. 45

  • Python: 1) Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline()...

    Python: 1) Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _____________________ print("Error") What should be placed in the blank so that the program will print Error instead of crashing if an exception occurs while opening or reading from the file? Group of answer choices a- except RuntimeError : b- except EnvironmentError : c- except IOError : d- except IndexError : 2) Consider the following code segment: line = "hello world!" parts = line.split()...

  • 1. How many times does the message, “Hello” get printed out by the code segment below?...

    1. How many times does the message, “Hello” get printed out by the code segment below? int count = 0; while (count < 32) {     printf(“Hello\n”);     count = count+4; } 2. What is the value of sum at the end of the following code segment? int sum = 0, index; for (index = 0; index < 5; index++)                 sum += 5; Group of answer choices

  • 31. The following code segment is syntactically correct:              int number{20};          cout << number <<...

    31. The following code segment is syntactically correct:              int number{20};          cout << number << setbase(16) << " " << number                               << setbase(10) << " " << number                                 << showpos << " " << number << endl;                 T__   F__       32. The following statement wants to determine if ‘count’ is outside the     range of 0 through 100:             if (count < 0 && count > 100)                                             T__   F__ 33. There is...

  • 4. Given the following code, int x = 5, n; do{ n = 0; for (int...

    4. Given the following code, int x = 5, n; do{ n = 0; for (int i = 0; i < x; i++) { n = n + x; System.out.println(n); } while (x > 1); a) What will be the value of x after the code segment is executed? Initial value of x 5 b) What is the output of the code segment? c) Explain how the flow of control moves in the given code segment. When explaining, show how...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT