aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Computer Science (GATE Exam) 2007 - Previous Question Paper Solution
  • Consider the following segment of C-code: ```c int j, n; ...
Multiple choice

Consider the following segment of C-code:

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

The number of comparisons made in the execution of the loop for any n > 0 is:

  1. [log2 n] + 1

  2. n

  3. [log2 n]

  4. [log2 n] + 2

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Keep practicing — related questions

  • Consider the following C code segment: int Is Prime (n) { int i, n; for (i = 2; i <= sqrt (n) ; i ++) if (n...
  • Consider the following C code segment: int Is Prime (n) { int i, n; for (i = 2; i <= sqrt (n) ; i ++) if (n...
  • What would be the output of the following C code? int i=1, j=1; int n = 1; if(n>0){i++;j--;}printf(i=%d, j=...
  • Consider the following C-program fragment in which i, j and n are integer variables. for( i = n, j = 0; i >...
  • Consider the following C-program fragment in which i, j and n are integer variables. for( i = n, j = 0; i >...
  • How many number of times will the loop mentioned below be executed? int x=5;int y=30;while(x<=y){ x=y/x; y=...
  • Consider the following C code segment. for (i - 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4* j ...
  • In C programming, what does I equal at the end of the following piece (snippet) of code? i =1; i *=5; i +=3;
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Data Structures and Algorithms (1518 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy