Scripting In C++ : Scripting Language! Hardest Trivia Quiz

45 Questions | Attempts: 97
Share

SettingsSettingsSettings
Scripting In C++ : Scripting Language! Hardest Trivia Quiz - Quiz

C++ is an object-oriented programming language, and it allows procedural programming for intensive functions of CPU and to provide control over hardware. The trivia quiz below is designed to test out what you know about scripting language in C++. DO you think you have what it takes to tackle it? Well give it a shot and find out!


Questions and Answers
  • 1. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;}Which of these is a valid variablename? P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;}Which of these is a valid variablename? P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} Which of these is a valid variable name?
    • A. 

      2ndMin

    • B. 

      __

    • C. 

      Auto

    • D. 

      None of These

  • 2. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} What is the output of the following code snippet? Main() { float x=0.1f; while(x<1.0) x += 0.1f; printf(“%f”, x); }
    • A. 

      1.0

    • B. 

      1.0000000

    • C. 

      1.1000000

    • D. 

      Floats can't be compared in a while

  • 3. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } What is the output in the following code int i; for(i=0; i<5; i++); printf(“%d\t”, i);
    • A. 

      0 1 2 3 4

    • B. 

      0 1 2 3 4 5

    • C. 

      5

    • D. 

      Compiler Error

  • 4. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} Void func(char **p) { p++; } int main() { char *a = “Hello, World”; func(&a); printf(“%s\n”,a); return 0; }
    • A. 

      Ello, World

    • B. 

      Hello, World

    • C. 

      Segmentation Fault

    • D. 

      Compiler Error

  • 5. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } Which of the following best describes the error in the code given below void main() { int p, *n; n = &p; scanf(''%d'', n), printf(''%d '', p); return 0; }
    • A. 

      Parameter to scanf should be &n, not n

    • B. 

      The variable p is uninitialized

    • C. 

      Scanf statement should be terminated by semicolon

    • D. 

      Cannot return 0 from main

  • 6. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } I was doing a long OS recognition program. Can you find an error in my code? print_Windows() { printf(“Hello, You are using MS Windows”); } print_MacOS() { printf(“Hello there, You are using Mac OS”); } print_Ubuntu() { printf(“Hello, You are using Ubuntu Linux”); } print_HP-UX() { printf(“Hello, You are using HP-UX”); }
    • A. 

      The functions dont have return types, so compiler error

    • B. 

      OS-specific functions cannot be executed in C, so runtime error

    • C. 

      C. Some other error

    • D. 

      D. Nothing, code runs fine

  • 7. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } What will be the value of x and y, assuming 4 bytes integer? int fun(int arr[10]) { x = sizeof(arr); } int main() { int arr[10]; y = sizeof(arr); fun(arr); }
    • A. 

      X=40, y=40

    • B. 

      X=4, y=40

    • C. 

      X=40, y=4

    • D. 

      X=4, y=4

  • 8. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } Find the output of the following code snippet int x = 190; printf(“%c\n”, !x);
    • A. 

      Prints A

    • B. 

      Prints nothing

    • C. 

      Error

    • D. 

      Compiler Dependant

  • 9. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } How many types of pre-processor directives are there in C
    • A. 

      4

    • B. 

      3

    • C. 

      7

    • D. 

      As many as the user wants

  • 10. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} What is FALSE about static functions?
    • A. 

      They can be called from other functions

    • B. 

      They can have return types other than int

    • C. 

      They can be called from other source files

    • D. 

      Their local variables are initialized every time they are called

  • 11. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } What is the output of the following code: extern int x; int main() { printf(“%d\n”,x); }
    • A. 

      0

    • B. 

      Garbage Value

    • C. 

      Runtime Error

    • D. 

      Compiler Error

  • 12. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } What is TRUE about void pointers?
    • A. 

      They can point to any other type of data

    • B. 

      They can be dereferenced

    • C. 

      They occupy no memory

    • D. 

      They cannot be passed as function arguments

  • 13. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} Given below are two statements. Which option relating to the statements is true? A: Every C program has to include stdio.h B: stdio.h contains functions like scanf and printf
    • A. 

      Statement A is true and Statement B is the reason for it

    • B. 

      Statement A is true but Statement B is not the reason for it

    • C. 

      Statement A is false but Statement B is correct

    • D. 

      Both the statements are false

  • 14. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } What is the error in the following code? #define VAL 15 int main () { #ifndef VAL while(1) { printf(“Hello”) } #else printf(“Hi”); }
    • A. 

      Pre-processors cant be defined inside main

    • B. 

      Main function does not return a value

    • C. 

      Semicolon missing after printf

    • D. 

      No Compiler Error

  • 15. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } How many times will the following loop body execute? unsigned int i; for(i=-1; i<0; i-- ) { ... }
    • A. 

      Infinite Loop

    • B. 

      Zero times

    • C. 

      One time

    • D. 

      Compilation Error

  • 16. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } What is the largest possible data type available in C standard?
    • A. 

      Long double

    • B. 

      Long

    • C. 

      Long long

    • D. 

      Long long double

  • 17. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} What is the maximum value that an int can hold?
    • A. 

      32267

    • B. 

      INT_MAX

    • C. 

      MAX_INT

    • D. 

      Cannot be determined

  • 18. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} What is the output of the following code? printf(“\nhi”); printf(“\bsa”); printf(“\rmo”);
    • A. 

      Hi sa mo

    • B. 

      Hsamo

    • C. 

      Moa

    • D. 

      Hisamo

  • 19. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } In which header file are the malloc, calloc and realloc functions found?
    • A. 

      Stdlib.h

    • B. 

      Alloc.h

    • C. 

      None of a and b

    • D. 

      Both a and b

  • 20. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} What will be the output: printf(“%x\n”, -1 << 4);
    • A. 

      -10

    • B. 

      Fffffff0

    • C. 

      Fffffffc

    • D. 

      None of these

  • 21. 
    P{margin-bottom:0.21cm;direction:ltr;color:rgb(0,0,0);}P.western{font-family:"Liberation Serif","Times New Roman",serif;font-size:12pt;}P.cjk{font-family:"WenQuanYi Micro Hei";font-size:12pt;}P.ctl{font-family:"Lohit Hindi";font-size:12pt;} What will be the output of the following code snippet? int arr[] = {1,2,3,4,5}; for (i=-1; i<(sizeof(arr)/sizeof(arr[0]))-1; i++) printf(“%d\t”, arr[i+1]);
    • A. 

      1 2 3 4 5

    • B. 

      Compiler Error

    • C. 

      Runtime Error

    • D. 

      No errors, but doesn't output anything

  • 22. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } Which of these will print the 3rd element of an array a?
    • A. 

      *(a+3)

    • B. 

      3[a]

    • C. 

      None of these

    • D. 

      Both a & b

  • 23. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } Which of these user-defined function definitions is illegal
    • A. 

      Int scanf(int);

    • B. 

      Int stdio(double);

    • C. 

      Int sizeof(void*);

    • D. 

      Int FUNCTION(int (*fp)(int));

  • 24. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } How many bytes does the following declaration takes in data segment of the memory? (Consider a 4-bytes int and 8-byte double) struct somestruct { int a; double b; char c; };
    • A. 

      13 bytes

    • B. 

      8 bytes

    • C. 

      Implementation dependant

    • D. 

      0 byte

  • 25. 
    P { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }P.western { font-family: "Liberation Serif","Times New Roman",serif; font-size: 12pt; }P.cjk { font-family: "WenQuanYi Micro Hei"; font-size: 12pt; }P.ctl { font-family: "Lohit Hindi"; font-size: 12pt; } Generally what is the size of an int in C?
    • A. 

      2 bytes

    • B. 

      4 bytes

    • C. 

      Cannot say, implementation dependant

    • D. 

      The word size of the compiler

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.