Ilp C++ Quiz Prelims 1

33 Questions | Total Attempts: 47

SettingsSettingsSettings
Please wait...
C Programming Quizzes & Trivia

ILP C++ Quiz


Questions and Answers
  • 1. 
    What is the output of the following snippet? int a=0101; int b=101; cout<<a<<” , ”<<b;
    • A. 

      0101,101

    • B. 

      101,101

    • C. 

      Compilation Error

    • D. 

      101 0110

  • 2. 
    What is the output of the following code ?   int i = 10;   int &r;  r = &i; cout<<i<<":"<<r;
    • A. 

      10 10

    • B. 

      Compilation Error

    • C. 

      10

    • D. 

      None of the above

  • 3. 
    What is the output of the following snippet ? class Test { }; int main() {  Test t;  cout<<sizeof(t);  return 0; }
    • A. 

      0

    • B. 

      1

    • C. 

      None of the above

    • D. 

      Compilation Error

  • 4. 
    Which of the following way is the correcy way to set a value 3.14 in a variable pi such that it can not be modified ?
    • A. 

      Float pi = 3.14F;

    • B. 

      #define pi 3.14F;

    • C. 

      Const float pi = 3.14F;

    • D. 

      Const float pi; pi = 3.14F

  • 5. 
    What is the output of the following snippet ? unsigned int a = 5; int b=2; int status = (a>b)?1:0; cout<<status;
    • A. 

      1

    • B. 

      0

    • C. 

      01

    • D. 

      10

  • 6. 
    What is the output of the following snippet ? int *p=10; cout<<*p;
    • A. 

      10

    • B. 

      Address of '10'

    • C. 

      Compilation Error

    • D. 

      None of the above

  • 7. 
    What is the output of the following code snippet ? int main() {    int a=1, b=2, c=3,d,e;    d=a,b,c;    e=(a,b,c);    cout<<d<<e;
    • A. 

      1,1

    • B. 

      1,3

    • C. 

      3,3

    • D. 

      3,1

  • 8. 
    What is the output of the following snippet ? int a=5.6; float b=5; cout<<a<<”\t”<<b;
    • A. 

      5.6,5

    • B. 

      5,5.0

    • C. 

      5,5 and warning

    • D. 

      Error

  • 9. 
    What is the output of the following snippet ? double a=10.5; double b=4.0 cout<<a%b<<” “<<a*b; cout<<” “<<a+b<<” “<<a-b; 
    • A. 

      2.5 5.0

    • B. 

      Compilation Error

    • C. 

      2

    • D. 

      None of the Above

  • 10. 
    What is the output of the following snippet ? char* const p="abc";  cout<<p; p=“x”; cout<<p;  
    • A. 

      Abc,x

    • B. 

      Abc,xbc

    • C. 

      Segmentation Fault

    • D. 

      Compilation Error

  • 11. 
    What is the output of the following snippet ? int main() {   int a=10;   {      a=20;     {        a=30;    cout<<a;      }            cout<<a;           }       cout<<a; }
    • A. 

      30,20,10

    • B. 

      30,30,30

    • C. 

      10,20,30

    • D. 

      Compilation Error

  • 12. 
    What is the output of the following snippet ? cout<<sizeof(NULL)<<" "<<sizeof("");
    • A. 

      0,0

    • B. 

      8,8

    • C. 

      8,1

    • D. 

      4,0

    • E. 

      4,1

    • F. 

      4,4

  • 13. 
    What is the output of the following snippet ? int a(2); int b=2; cout<<a<<”\t”<<b;
    • A. 

      2,2

    • B. 

      Compilation Error

    • C. 

      Garbage Value, 2

    • D. 

      2,Garbage Value

  • 14. 
    What is the output of the following snippet ? int main() {    cout<<a;    return 0; } int a=10;
    • A. 

      10

    • B. 

      0

    • C. 

      Runtime Error

    • D. 

      Compilation Error

  • 15. 
    What is the Output of the following code ? int a=1,b=2; a^=b^=a^=b; cout<<a<<" "<<b;
    • A. 

      1,2

    • B. 

      1,1

    • C. 

      2,1

    • D. 

      2,2

  • 16. 
    What is the output of the following snippet ? int a = 5+NULL; cout<<a;
    • A. 

      5

    • B. 

      NULL

    • C. 

      Error

    • D. 

      None Of the Above

  • 17. 
    What is the output of the following snippet ? float a=3.5;   a++; char c='A'; c++; int i=-2; i++; cout<<a<<"\t"<<c<<"\t"<<i;
    • A. 

      3.6 B -3

    • B. 

      4.6 B -1

    • C. 

      4.5 B -1

    • D. 

      Compilation Error

  • 18. 
    What is the output of the following snippet ? int main() {   int a=1; cout<<a+++++a; }
    • A. 

      3

    • B. 

      4

    • C. 

      Compilation Error

    • D. 

      None of the above

  • 19. 
    What is the output of the following snippet ? #define SQUARE(X) (X*X) int main() {  cout<<SQUARE(5);  cout<<SQUARE(2+3); }
    • A. 

      25,25

    • B. 

      25,13

    • C. 

      Compilation Error

    • D. 

      None Of the above

  • 20. 
    What is the output of the following snippet? int a=10; cout<<a++*a++<<”\t”; cout<<a++*++a<<”\t”;
    • A. 

      110,156

    • B. 

      100,169

    • C. 

      256,225

    • D. 

      None Of the above

  • 21. 
    What is the output of the following snippet ? cout<<2/9<<"\t"; cout<<2.0/9<<"\t"; cout<<2/9.0<<"\t"; cout<<2.0/9.0<<"\t";
    • A. 

      0.2 0 0 0.2

    • B. 

      0 0 0 0.2

    • C. 

      0 0.2 0.2 0.2

    • D. 

      0 0.2 0 0.2

  • 22. 
    What is the output of the following snippet ? short int a=1; a=a<<15; cout<<a;
    • A. 

      -32768

    • B. 

      32767

    • C. 

      30

    • D. 

      None of the Above

  • 23. 
    What is the output of the following snippet  ?   int array[10] = {2,1,4,5};   int &r = array[2];   cout<<*r;
    • A. 

      4

    • B. 

      Compilation Error

    • C. 

      1

    • D. 

      None of the above

  • 24. 
    What is the output of the following code snippet ? int a=1,b=2; int x=!!a; int y=!a&&b; cout<<x<<”\t”<<y;
    • A. 

      1 1

    • B. 

      1 0

    • C. 

      0 0

    • D. 

      True false

  • 25. 
    What is the output of the following code snippet ? int a=1,b=1; int x=(a<2)&&(b=100); int y=(a==b)&&(a!=b); cout<<x<<”\t”<<y<<”\t”<<a<<”\t”<<b;
    • A. 

      1 1 1 0

    • B. 

      0 100 0 0

    • C. 

      1 0 1 1

    • D. 

      1 0 1 100