C Expressions and Switch Statements

Expressions in C

19 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the output of the given C code?

int main()
{
printf( "%lf",round(hypot(4+1,9-1)));
return 0;
}

  1. 13
  2. 9
  3. 12
  4. 16
  5. 22
Question 2 Multiple Choice (Single Answer)

What is the output of the given C code?

int main()
{
printf( "%lf",round(hypot(4+1,9-1)));
return 0;
}

  1. 13
  2. 9
  3. 12
  4. 16
  5. 0
Question 3 Multiple Choice (Single Answer)

What is the output of the given C code?

void ret(int a, int b)
{
double res = pow(a,b);
printf(\\\\\\\\n%d,res);
}
int main()
{
int i = (1048576>>8>>3>>4>>3);
int y = 1024>>4>>3;
ret(i,y);
printf(\\\\\\\\n%d,i^y);
return 0;
}

  1. 0 12
  2. 65536.0 16
  3. 25536.012
  4. 25536.012
  5. Compiler error
Question 4 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = 1024<<8<<3>>8>>3;
switch(i)
{
default : break;
case 1048576/(34*32) : printf("Case 1");
case 1073741824/(2*32*4*32*16*8*2) : printf("Case 2");
case 1048576/(32*30*4) : printf("Case 3");
}
return 0;
}

  1. Case 1 Case 2 Case 3
  2. Case 2 Case 3
  3. Case 3
  4. No output
  5. Compiler error
Question 5 Multiple Choice (Single Answer)

What is the output of the given C code?

int main()
{
bool i=1;
switch(round(hypot(114,123))) // Line 1
{
default : printf("Default Case");
case 128<<6<<3 : printf("Case 1");
case 9072/54 : printf("Case 2");
case 128<<4<<2 : printf("Case 3");
}
return 0;
}

  1. Default Case Case 1 Case 2 Case 3
  2. Case 1 Case 2 Case 3
  3. Case 2 Case 3
  4. Case 3
  5. Compilation error
Question 6 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = (1048576>>8>>3>>8>>3) + + - + (1024<<8<<3>>8>>3);
switch(i++) // Line 1
{
case 1024 : printf("Hello");
case 1025 : printf("How r u?");
case 512 : printf("Bye");
case 513 : printf("Bye Bye");
default : printf("Good Bye");
}
}

  1. Hello How r u? Bye Bye Bye Good Bye
  2. How r u? Bye Bye Bye Good Bye
  3. Bye Bye Bye Good Bye
  4. Bye Bye Good Bye
  5. Good Bye
Question 7 Multiple Choice (Single Answer)

What is the output of the given C code?

int main()
{
bool i;
if(i) switch(i++) // Line 1
{
default : printf("No Value");
case 0 : printf("\\ni is 0");
case 1 : printf("\\ni is 1");
case 2 : printf("\\ni is 2");
}
}

  1. No value. i is 0i is 1i is 2
  2. i is 0i is 1i is 2
  3. i is 1i is 2
  4. No output
  5. Compilation error
Question 8 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = 1048576>>8>>3>>8>>3;
switch(i++ - 1) // Line 1
{
case "-1" : printf("Case -1");
case "1" : printf("Case 1");
default : break;
case "0" : printf("Case 0");
}
}

  1. Case -1 Case 1 Case 0
  2. Case -1 Case 1
  3. Case 0
  4. Case 1
  5. Compiler error
Question 9 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i= (int)round(hypot(114,123));
switch(i) // Line 1
{
default : printf("\\nDefault Case");
case 128<<6<<3 : printf("\\nCase 1");
case 9072/54 : printf("\\nCase 2");
case 128<<4<<2 : printf("\\nCase 3");
}
}

  1. Default Case Case 1 Case 2 Case 3
  2. Case 1 Case 2 Case 3
  3. Case 2 Case 3
  4. Case 3
  5. Compilation error
Question 10 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = 1024<<8<<3>>8>>3;
switch(i)
{
default : printf("Default");
case 1048576/(34*32) : printf("Case 1");
case 1073741824/(2*32*4*32*16*8*2) : printf("Case 2");
case 1048576/(32*32) : printf("Case 3");
}
}

  1. Default Case 1 Case 2 Case 3
  2. Case 1 Case 2 Case 3
  3. Case 2 Case 3
  4. Case 3
  5. Compiler error
Question 11 Multiple Choice (Single Answer)

What is the output of the given C code?

void ret(int a, int b)
{
double res = pow(a,b);
printf("%lf",res);
}
int main()
{
int i = (1048576>>8>>3>>4>>3);
int y = 1024>>4>>3; ret(i,y);
}

  1. 25686.0
  2. 25656.0
  3. 65556.0
  4. 65536.0
  5. Compilation error
Question 12 Multiple Choice (Single Answer)

What is the output of the given C code?

void ret(int a, int b)
{
double res = pow(a,b);
printf("\\n%lf",res);
}
int main()
{
int i = (1048576>>8>>3>>4>>3);
int y = 1024>>4>>3;
ret(i,y);
printf("\\n%d",i^y);
return 0;
}

  1. 65536.0 12
  2. 65536.0 16
  3. 25536.012
  4. 25536.011
  5. Compiler error
Question 13 Multiple Choice (Single Answer)

What is the output of the given C code?

int main()
{
boolean i=1;
switch(round(hypot(114,123))) // Line 1
{
default : printf("Default Case");
case 128<<6<<3 : printf("Case 1");
case 9072/54 : printf("Case 2");
case 128<<4<<2 : printf("Case 3");
}
return 0;
}

  1. Default Case Case 1 Case 2 Case 3
  2. Case 1 Case 2 Case 3
  3. Case 2 Case 3
  4. Case 3
  5. Compilation error
Question 14 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = 1024<<8<<3>>8>>3;
switch(i)
{
default : printf("Default");
case 1048576/(34*32) : printf("Case 1");
case 1073741824/(2*32*4*32*16*8) : printf("Case 2");
case 1048576/(32*32) : printf("Case 3");
}
return 0;
}

  1. Default Case 1 Case 2 Case 3
  2. Case 1 Case 2 Case 3 is incorrect
  3. Case 2 Case 3
  4. Case 3
  5. Compiler error
Question 15 Multiple Choice (Single Answer)

What is the output of the given C code?

void ret(int a, int b)
{
double res = pow(a,b);
printf("%d",res);
}
int main()
{
int i = (1048576>>8>>3>>4>>3);
int y = 1024>>4>>3;
ret(i,y);
}

  1. 25686.0
  2. 25656.0
  3. 0
  4. 65536.0
  5. Compilation error
Question 16 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = 1048576>>8>>3>>8>>3;
switch(i++ - 1) // Line 1
{
case -1 : printf("Case -1");
case 1 : printf("Case 1");
default : break;
case 0 : printf("Case 0");
}
return 0;
}

  1. Case - 1 Case 1
  2. Case - 1 Case 1 Case 0
  3. Case 0
  4. No output
  5. Error at Line 1
Question 17 Multiple Choice (Single Answer)

What is the output of the given C code?

int main()
{
int i;
switch(i) // Line 1
{
default : printf("No Value\\n");
case 0 : printf("i is 0\\n");
case 1 : printf("i is 1");
}
return 0;
}

  1. No value. i is 0i is 1
  2. i is 0i is 1
  3. i is 1
  4. No output
  5. Compilation error
Question 18 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = 1048576>>8>>3>>8>>3;
switch(1 + i++ - 1) // Line 1
{
case 0 : printf("\\n%d",1024<<8<<3>>8>>3);
case -1 : printf("\\n%d",1024<<2>>3<<2);
default : break;
case 1 : printf("\\n%d",1024<<3<<8>>3>>3);
}
return 0;
}

  1. 32768
  2. 10242048
  3. 2048
  4. No output
  5. Error at Line 1
Question 19 Multiple Choice (Single Answer)

What is the output of the given C program?

int main()
{
int i = (1048576>>8>>3>>8>>3) + + - + (1024<<8<<3>>8>>3);
switch(i) // Line 1
{
default : printf("Good Bye");
case 1024 : printf("\\n%d\\n",1024<<8<<3>>8>>3);
case 512 : printf("%d\\n",1024<<2>>3<<2);
case 1 : printf("%d\\n",1024<<3<<8>>3>>3);
}
return 0;
}

  1. Good Bye 1024 2048 32768
  2. 1024 2048 32768
  3. 2048 32768
  4. 32768
  5. Compilation error