Coders Challenge Group A (Round 1)

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Hrithik
H
Hrithik
Community Contributor
Quizzes Created: 1 | Total Attempts: 203
Questions: 60 | Attempts: 203

SettingsSettingsSettings
Coders Challenge Group A (Round 1) - Quiz


Questions and Answers
  • 1. 

    What is the meaning of the following declaration? int(*p[5])();

    • A.

      P is pointer to function

    • B.

      P is array of pointer to function

    • C.

      P is pointer to such function which return type is the array

    • D.

      P is pointer to array of function

    Correct Answer
    B. P is array of pointer to function
    Explanation
    The declaration "int(*p[5])();" means that p is an array of 5 pointers to functions that return an integer. Each element in the array can point to a different function that returns an integer.

    Rate this question:

  • 2. 

    What is the output of this program?      #include    using namespace std;    int main()    {         int arr[] = {4, 5, 6, 7};         int *p = (arr + 1);         cout << *arr + 9;         return 0;    }

    • A.

        12

    • B.

      5

    • C.

      13

    • D.

      Error

    Correct Answer
    C. 13
    Explanation
    The program declares an array `arr` of integers with values {4, 5, 6, 7}. It then declares a pointer `p` and assigns it the address of the second element of `arr` (arr + 1).

    The line `cout

    Rate this question:

  • 3. 

    . int main() { int row[20],i,sum=0; int *p=row; for(i=0;i<20;i++) *(p+i)=1; for(i=0;i<20;i+=sizeof(int)) sum+=*(p+i); printf("sum=%d\n",sum); }

    • A.

      Sum=10

    • B.

      Sum=40

    • C.

      Sum=19

    • D.

      Sum=60

    Correct Answer
    A. Sum=10
    Explanation
    The given code initializes an array 'row' with 20 elements and assigns the value 1 to each element using a pointer 'p'. Then, it calculates the sum of the elements in the array by iterating over the elements using pointer arithmetic. Since the size of an integer is typically 4 bytes, the loop increments the pointer by 4 in each iteration. Therefore, it only considers every 4th element in the array, resulting in a sum of 10.

    Rate this question:

  • 4. 

    #include<stdio.h> int main() {        int a=10,b=10;       if(a==5)          b--;      printf("%d,%d",a,b--); }

    • A.

      A=10, b=9

    • B.

      A=10, b=8

    • C.

      A=5, b=9

    • D.

      A=5, b=8

    Correct Answer
    C. A=5, b=9
    Explanation
    The if statement checks if the value of 'a' is equal to 5. Since 'a' is not equal to 5, the code inside the if statement is not executed. Therefore, the value of 'b' remains the same, which is 10. However, the value of 'b' is decremented by 1 after it is printed, resulting in the final value of 'b' being 9.

    Rate this question:

  • 5. 

    Which is valid C expression?  

    • A.

      Int my_num = 100,000;

    • B.

       int my_num = 100000;

    • C.

      Int my num = 1000;

    • D.

      Int $my_num = 10000;

    Correct Answer
    B.  int my_num = 100000;
    Explanation
    The correct answer is "int my_num = 100000;". This is a valid C expression because it follows the syntax rules of C programming. The variable "my_num" is declared as an integer and assigned the value of 100000. The other options have syntax errors - the first option has a comma in the number which is not allowed, the third option has a space in the variable name which is not allowed, and the fourth option starts with a dollar sign which is not allowed.

    Rate this question:

  • 6. 

    What is the use of Namespace?

    • A.

      To encapsulate the data

    • B.

      To structure a program into logical units

    • C.

      Encapsulate the data & structure a program into logical units

    • D.

      None of the mentioned

    Correct Answer
    B. To structure a program into logical units
    Explanation
    The use of a namespace is to structure a program into logical units. Namespaces provide a way to organize code and prevent naming conflicts. They allow for better organization and management of code by grouping related classes, functions, and variables together. This helps improve code readability, maintainability, and reusability. By structuring a program into logical units using namespaces, it becomes easier to understand and navigate the codebase, making development and debugging more efficient.

    Rate this question:

  • 7. 

    Which data structure type is NOT linear from the following?

    • A.

      Doubly Link List

    • B.

      2D Array

    • C.

      Binary Search Tree

    • D.

      Queue

    Correct Answer
    C. Binary Search Tree
    Explanation
    A binary search tree is a non-linear data structure as it does not follow a sequential order. It is a tree-like structure where each node has at most two children, a left child and a right child. The nodes are arranged in a specific order based on their values, with the left child having a smaller value and the right child having a larger value. This hierarchical structure allows for efficient searching and sorting operations. Unlike linear data structures such as doubly linked lists, 2D arrays, and queues, a binary search tree does not have a linear arrangement of elements.

    Rate this question:

  • 8. 

    Which of the followings is/are pointer-to-member declarator?

    • A.

       ->*

    • B.

      .*

    • C.

      ::*

    • D.

      Both a and b

    Correct Answer
    C. ::*
    Explanation
    The correct answer is "::*". This is because "::" is the scope resolution operator, and "*" is the pointer operator. When used together, "::*" is used to declare a pointer to a member of a class.

    Rate this question:

  • 9. 

    What will happen in this code? int a = 100, b = 200;    int *p = &a, *q = &b;    p = q;

    • A.

      B is assigned to a

    • B.

      P now points to b

    • C.

      A is assigned to b

    • D.

      Q now points to a

    Correct Answer
    B. P now points to b
    Explanation
    In this code, two variables `a` and `b` are declared and assigned values of 100 and 200 respectively. Then, two pointers `p` and `q` are declared and assigned the addresses of `a` and `b` respectively. Finally, the value of `q` is assigned to `p`, which means `p` now points to `b`.

    Rate this question:

  • 10. 

    What does the following declaration mean?    int (*ptr)[10];

    • A.

      Ptr is array of pointers to 10 integers

    • B.

      Ptr is a pointer to an array of 10 integers

    • C.

      Ptr is an array of 10 integers

    • D.

      Ptr is an pointer to array

    Correct Answer
    B. Ptr is a pointer to an array of 10 integers
    Explanation
    The declaration "int (*ptr)[10]" means that "ptr" is a pointer to an array of 10 integers. The parentheses around "*ptr" indicate that "ptr" is a pointer, and the "[10]" indicates that it is a pointer to an array of 10 integers.

    Rate this question:

  • 11. 

    #include <stdio.h>     void main()     {         int x = 0;         if (x == 0)             printf("hi");         else             printf("how are u");             printf("hello");     }

    • A.

      Hi

    • B.

      How are you

    • C.

      Hello

    • D.

      Hihello

    Correct Answer
    D. Hihello
    Explanation
    The correct answer is "hihello" because the variable x is initialized to 0, and the if statement checks if x is equal to 0. Since x is indeed equal to 0, the code inside the if statement is executed, which prints "hi". After that, the code continues to execute the next line, which prints "hello". So the output will be "hihello".

    Rate this question:

  • 12. 

    Which of the following is not a valid variable name declaration?

    • A.

      Int _a3;

    • B.

      Int a_3;

    • C.

      Int 3_a;

    • D.

      Int _3a;

    Correct Answer
    C. Int 3_a;
    Explanation
    The variable name declaration "int 3_a;" is not valid because it starts with a number, which is not allowed in variable names in most programming languages. Variable names should start with a letter or an underscore.

    Rate this question:

  • 13. 

    #include <stdio.h>     void main()     {         int x = 4, y, z;         y = --x;         z = x--;         printf("%d%d%d", x,  y, z);     }

    • A.

      3 2 3

    • B.

      2 3 3

    • C.

       3 2 2

    • D.

      2 3 4

    Correct Answer
    B. 2 3 3
    Explanation
    The code snippet initializes the variable x with the value 4. Then, the value of x is decremented by 1 using the pre-decrement operator --x and assigned to the variable y. So, y becomes 3. Next, the value of x is decremented by 1 using the post-decrement operator x-- and assigned to the variable z. So, z becomes 3. Finally, the printf statement prints the values of x, y, and z, which are 2, 3, and 3 respectively. Therefore, the correct answer is 2 3 3.

    Rate this question:

  • 14. 

    What is the output of this program?     #include <iostream>     using namespace std;     enum colour {         green, red, blue, white, yellow, pink     };     int main()     { cout << green<< red<< blue<< white<< yellow<< pink;         return 0;     }

    • A.

      012345

    • B.

      123456

    • C.

      123456

    • D.

      Runtime error

    Correct Answer
    A. 012345
    Explanation
    The program defines an enumeration called "colour" with six values: green, red, blue, white, yellow, and pink. In the main function, it prints the values of the enumeration variables in sequence without any separators. Therefore, the output of the program will be the concatenation of the integer values of the enumeration variables: 012345.

    Rate this question:

  • 15. 

    #include <stdio.h>     void main()     {         int a = 5, b = -7, c = 0, d;         d = ++a && ++b || ++c;         printf("\n%d%d%d%d", a,  b, c, d);     }

    • A.

       6 -6 0 0

    • B.

       6 -5 0 1

    • C.

       -6 -6 0 1

    • D.

      6 -6 0 1

    Correct Answer
    D. 6 -6 0 1
    Explanation
    The code snippet initializes variables a, b, and c with values 5, -7, and 0 respectively. The expression d = ++a && ++b || ++c is then evaluated. Since the && operator has higher precedence than the || operator, the expressions ++a and ++b are evaluated first. The value of a is incremented to 6 and b is incremented to -6. The result of the logical AND operation (6 && -6) is false (0). Since the result of the logical AND operation is false, the expression ++c is not evaluated. The value of d is assigned the value of the logical OR operation between the result of the logical AND operation and ++c, which is true (1). Therefore, the final values of a, b, c, and d are 6, -6, 0, and 1 respectively.

    Rate this question:

  • 16. 

    #include <stdio.h>     int main()     {         float x = 'a';         printf("%f", x);         return 0;     }

    • A.

      A  

    • B.

      Run time error

    • C.

      A.0000000

    • D.

      97.000000

    Correct Answer
    D. 97.000000
    Explanation
    The code snippet declares a variable 'x' of type float and assigns it the ASCII value of the character 'a'. When the program prints the value of 'x' using the '%f' format specifier, it converts the ASCII value of 'a' (which is 97) into a floating-point number and prints it as "97.000000".

    Rate this question:

  • 17. 

    . Which one of the following is correct about the statements given below? All function calls are resolved at compile-time in Procedure Oriented Programming. All function calls are resolved at compile-time in OOPS.

    • A.

      Only II is correct.     

    • B.

      Both I and II are correct.

    • C.

      Only I is correct.

    • D.

      Both I and II are incorrect.

    Correct Answer
    C. Only I is correct.
    Explanation
    In Procedure Oriented Programming, all function calls are resolved at compile-time. This means that the compiler determines the address of the function to be called during the compilation process. On the other hand, in Object-Oriented Programming (OOPS), function calls are resolved at runtime using dynamic binding or late binding. Therefore, only statement I is correct, stating that all function calls are resolved at compile-time in Procedure Oriented Programming.

    Rate this question:

  • 18. 

    Which operator has highest precedence in * / % ?

    • A.

      %

    • B.

      /

    • C.

      *

    • D.

      All have same precedence

    Correct Answer
    D. All have same precedence
    Explanation
    The operators * (multiplication), / (division), and % (modulus) all have the same precedence. This means that they are evaluated from left to right in the order they appear in an expression. Therefore, there is no operator that has a higher precedence than the others in this case.

    Rate this question:

  • 19. 

    #include <stdio.h>     int main()     {         enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};         printf("PEACH = %d\n", PEACH);     }

    • A.

      PEACH = 3

    • B.

      PEACH = 4

    • C.

      PEACH = 5

    • D.

      PEACH = 6

    Correct Answer
    C. PEACH = 5
    Explanation
    In the given code, an enumeration is defined with four constants: ORANGE = 5, MANGO = 6, BANANA = 4, and PEACH. Since PEACH is not explicitly assigned a value, it will be assigned the next available integer value, which is 5. Therefore, the output of the printf statement will be "PEACH = 5".

    Rate this question:

  • 20. 

    The keyword ‘break’ cannot be simply used within _________

    • A.

      Do-while

    • B.

      If-else

    • C.

      For

    • D.

      While

    Correct Answer
    B. If-else
    Explanation
    The keyword 'break' cannot be simply used within the if-else statement. The 'break' statement is used to exit a loop or switch statement. However, the if-else statement is not a loop or switch statement, but a conditional statement. Therefore, using 'break' within the if-else statement would result in a syntax error.

    Rate this question:

  • 21. 

    #include <stdio.h> struct student { char a[5]; }; void main() { struct student s[] = {"hi", "hey"}; printf("%c", s[0].a[1]); }

    • A.

      H

    • B.

      I

    • C.

      E

    • D.

      Y

    Correct Answer
    B. I
    Explanation
    The code snippet declares a structure named "student" with a character array "a" of size 5. In the main function, an array of "student" structures named "s" is declared and initialized with two string literals "hi" and "hey". The printf statement then prints the character at index 1 of the first element of the array "s", which is 'i'.

    Rate this question:

  • 22. 

    Which value can we not assign to reference?

    • A.

      Integer

    • B.

      Floating

    • C.

       unsigned

    • D.

       null

    Correct Answer
    D.  null
    Explanation
    We cannot assign the value "null" to a reference. In programming, "null" represents the absence of a value or a non-existent object. References are used to point to objects or variables, and they must always refer to a valid memory location. Assigning "null" to a reference would mean that the reference does not point to any object or variable, which is not allowed.

    Rate this question:

  • 23. 

    Identify the incorrect option.

    • A.

      Enumerators are constants

    • B.

      Enumerators are user-defined types

    • C.

      Enumerators are same as macros

    • D.

      Enumerator values start from 0 by default

    Correct Answer
    C. Enumerators are same as macros
    Explanation
    The given answer is incorrect because enumerators are not the same as macros. Enumerators are used to define named constants in C programming language, while macros are used to define code snippets that are replaced by the preprocessor before compilation. Macros can be used for various purposes, including defining constants, but they are not the same as enumerators.

    Rate this question:

  • 24. 

    Which keyword is used to define the user defined data types?  

    • A.

      Def

    • B.

      Union

    • C.

      Typedef

    • D.

       type

    Correct Answer
    C. Typedef
    Explanation
    The keyword "typedef" is used to define user-defined data types in programming. It allows the programmer to create a new name for an existing data type, making the code more readable and easier to understand. By using "typedef", the programmer can create aliases for complex data types, such as structures or arrays, simplifying the code and making it more manageable.

    Rate this question:

  • 25. 

    Printf(“%d”,printf(“tim”));

    • A.

      Results in a syntax error

    • B.

      Outputs tim3

    • C.

      Outputs garbage

    • D.

      Outputs tim and terminates abruptly

    Correct Answer
    B. Outputs tim3
    Explanation
    The given code snippet is using the printf function to print the string "tim" and then printing the return value of the inner printf function. The inner printf function will print "tim" and return the number of characters printed, which is 3. Therefore, the output of the code will be "tim3".

    Rate this question:

  • 26. 

    Which operator is having the highest precedence?

    • A.

      Postfix

    • B.

      Unary

    • C.

      Shift

    • D.

      Equality

    Correct Answer
    A. Postfix
    Explanation
    The postfix operator has the highest precedence among the given options. This means that it is evaluated first before any other operators. The postfix operator is used to increment or decrement a variable after it has been used in an expression. For example, if we have the expression "a++", the value of "a" will be incremented after it is used in the expression.

    Rate this question:

  • 27. 

    Which is used to create a pure virtual function ?

    • A.

      $

    • B.

      =0

    • C.

       &

    • D.

      !

    Correct Answer
    B. =0
    Explanation
    The "=0" syntax is used to create a pure virtual function in C++. A pure virtual function is a function that is declared in a base class but has no implementation. It is meant to be overridden by derived classes, forcing them to provide their own implementation. The "=0" syntax is added at the end of the function declaration to indicate that it is pure virtual.

    Rate this question:

  • 28. 

    #include <stdio.h> int fun(int arr[]) {    arr = arr+1;    printf("%d ", arr[0]); } int main(void) {    int arr[2] = {10, 20};    fun(arr);    printf("%d", arr[0]);    return 0; }

    • A.

      Compiler Error

    • B.

      20 10

    • C.

      20 20

    • D.

      10 10

    Correct Answer
    B. 20 10
    Explanation
    The program will output "20 10". The function fun() receives the array as a parameter, but when the pointer arr is incremented by 1, it points to the second element of the array. So, when arr[0] is printed inside the function, it prints the second element of the array, which is 20. However, the original array in the main() function remains unchanged, so when arr[0] is printed outside the function, it prints the first element of the array, which is 10.

    Rate this question:

  • 29. 

    #include <stdio.h> int main() {     int x;     x = 5 > 8 ? 10 : 1 != 2 < 5 ? 20 : 30;     printf("Value of x:%d", x);     return 0; }

    • A.

      X=10

    • B.

      X=20

    • C.

      X=30

    • D.

      Error

    Correct Answer
    C. X=30
    Explanation
    The expression in the ternary operator is evaluated from left to right. The first condition, 5 > 8, is false, so the value after the colon, 30, is assigned to x. Therefore, the value of x is 30.

    Rate this question:

  • 30. 

    #include <iostream> using namespace std; int main() {     int x = 3, k;     while (x-- >= 0) {         printf("%d  ", x);     }     return 0; }

    • A.

      3 2 1 0

    • B.

      2 1 0 -1

    • C.

      Infinite loop

    • D.

      -65535

    Correct Answer
    B. 2 1 0 -1
    Explanation
    The code snippet initializes the variable x to 3 and enters a while loop. In each iteration of the loop, the value of x is printed and then decremented by 1. The loop continues as long as x is greater than or equal to 0.

    In the first iteration, x is 3 and is printed. Then, x is decremented to 2. In the second iteration, x is 2 and is printed. Then, x is decremented to 1. In the third iteration, x is 1 and is printed. Then, x is decremented to 0. In the fourth iteration, x is 0 and is printed. Then, x is decremented to -1.

    After the fourth iteration, the condition x >= 0 is no longer true, so the loop ends. Therefore, the output of the code is "2 1 0 -1".

    Rate this question:

  • 31. 

    Consider the following definition in c programming language struct node {     int data;     struct node * next; } typedef struct node NODE; NODE *ptr; Which of the following c code is used to create new node?

    • A.

      Ptr = (NODE*)malloc(sizeof(NODE));

    • B.

      Ptr = (NODE*)malloc(NODE);

    • C.

      Ptr = (NODE*)malloc(sizeof(NODE*));

    • D.

      Ptr = (NODE)malloc(sizeof(NODE));

    Correct Answer
    A. Ptr = (NODE*)malloc(sizeof(NODE));
    Explanation
    The correct answer is "ptr = (NODE*)malloc(sizeof(NODE));". This code is used to allocate memory for a new node of type NODE. The malloc function is used to dynamically allocate memory, and the sizeof operator is used to determine the size of the NODE structure. The result of the malloc function is cast to a pointer of type NODE* and assigned to the ptr variable, indicating that ptr now points to the newly allocated memory for the new node.

    Rate this question:

  • 32. 

    #include <iostream> using namespace std; class Test { public:       Test() { cout << "Hello from Test() "; } } a; int main() {     cout << "Main Started ";     return 0; }

    • A.

      Main Started

    • B.

      Main Started Hello from Test()

    • C.

      Hello from Test() Main Started

    • D.

      Compiler Error: Global objects are not allowed

    Correct Answer
    C. Hello from Test() Main Started
    Explanation
    The correct answer is "Hello from Test() Main Started". This is because when the program is executed, the main function is called first. The line "cout

    Rate this question:

  • 33. 

    #include <stdio.h> int main() {     int i = 25;     int* j;     int** k;     j = &i;     k = &j;     printf("%u %u %u ", k, *k, **k);     return 0; }

    • A.

      Address address value

    • B.

      Address value value

    • C.

      Address address address

    • D.

      Compilation error  

    Correct Answer
    A. Address address value
    Explanation
    The correct answer is "address address value" because the code declares a variable `i` with the value 25. Then, it declares a pointer `j` and a double pointer `k`. `j` is assigned the address of `i`, and `k` is assigned the address of `j`. When printing, `k` represents the address of `j`, `*k` represents the value stored at the address of `j` (which is the address of `i`), and `**k` represents the value stored at the address of `i`, which is 25.

    Rate this question:

  • 34. 

    Which of the following data type will throw an error on modulus operation(%)?

    • A.

      Char

    • B.

      Short

    • C.

      Int

    • D.

       float

    Correct Answer
    D.  float
    Explanation
    The modulus operator (%) is used to find the remainder of a division operation. It can only be used with integer data types. Since float is a floating-point data type, it cannot be used with the modulus operator and will throw an error.

    Rate this question:

  • 35. 

    The sizeof(void) in a 32-bit C is_____

    • A.

      0

    • B.

      1

    • C.

      2

    • D.

      4

    Correct Answer
    B. 1
    Explanation
    In C programming language, the "void" keyword is used to indicate that a function does not return a value. The "sizeof" operator is used to determine the size of a data type in bytes. In a 32-bit C system, the size of "void" is typically 1 byte. This is because "void" does not have any specific size or memory representation, but it is usually assigned the smallest possible size of 1 byte. Therefore, the correct answer is 1.

    Rate this question:

  • 36. 

    What is the output of the following code? #include <stdio.h>     int main()     {         int a = 1;         switch (a)         {         case a:             printf("Case A ");         default:             printf("Default");         }     }

    • A.

      Case A

    • B.

      Default

    • C.

      Case A Default

    • D.

      Compile time error

    Correct Answer
    D. Compile time error
    Explanation
    The code will result in a compile-time error because the value of the case statement in the switch statement must be a constant expression. In this case, the value of 'a' is not a constant expression as it is a variable.

    Rate this question:

  • 37. 

    #include <iostream> using namespace std; int main() {      int i;    for (i=0; i<3; i++);           cout << "hello!" <<i;    return 0; }

    • A.

      Hello!1

    • B.

      Hello!4

    • C.

      Hello!5

    • D.

      Hello!3

    Correct Answer
    D. Hello!3
    Explanation
    The correct answer is "hello!3" because the for loop runs 3 times, incrementing the value of i each time. After the loop, the value of i is 3, so when it is printed out with the "hello!" string, it becomes "hello!3".

    Rate this question:

  • 38. 

    #include<iostream> using namespace std; int x=20;  int main() {     int x = 10;      cout << "Value of global x is " << ::x << endl;     return 0; }

    • A.

      10 20

    • B.

      10

    • C.

      20

    • D.

      Error

    Correct Answer
    C. 20
    Explanation
    The correct answer is 20 because the global variable x has a value of 20, which is printed using the scope resolution operator (::x) in the cout statement. The local variable x inside the main function is not used or printed, so it does not affect the output.

    Rate this question:

  • 39. 

    What is the output of the following code? #include <iostream>     using namespace std;     int main ( )     {         static double i;         i = 20;         cout << sizeof(i);         return 0;     }

    • A.

      4

    • B.

      2

    • C.

      8

    • D.

      Garbage

    Correct Answer
    C. 8
    Explanation
    The output of the code is 8. The variable "i" is declared as a static double, which means it has a size of 8 bytes in memory. The sizeof() function is used to determine the size of the variable, and it returns the size in bytes. Therefore, when we print the result of sizeof(i), it will output 8.

    Rate this question:

  • 40. 

    What is the output of the following program?     #include <iostream>     using namespace std;     int main()     {         int num1 = 10;         float num2 = 20;         cout << sizeof(num1 + num2);         return 0;     }

    • A.

      2

    • B.

      4

    • C.

      8

    • D.

      Garbage

    Correct Answer
    B. 4
    Explanation
    The output of the program is 4. The sizeof() function is used to determine the size in bytes of a variable or data type. In this case, num1 and num2 are added together, resulting in a float value. The sizeof() function then returns the size in bytes of this float value, which is 4 bytes.

    Rate this question:

  • 41. 

    Struct stock { int scale; char code[10]; } S={11,“food”}; int main() { printf(“%d”,scale); }

    • A.

      Undefined symbol val   

    • B.

      11

    • C.

      ASCII value of food   

    • D.

      ASCII value of 11

    Correct Answer
    B. 11
    Explanation
    The correct answer is 11. In the given code, a struct named "stock" is defined with two members: an integer "scale" and a character array "code". An instance of this struct named "S" is declared and initialized with the values 11 and "food" respectively. In the main function, the value of the "scale" member of the "S" instance is printed using the printf function. Since "scale" is a member of the struct and not a separate variable, it should be accessed using the dot operator (S.scale) instead of just "scale". Therefore, the correct answer is 11.

    Rate this question:

  • 42. 

    1. #include <iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int *arr[ ] = {&a, &b, &c}; cout << arr[1]; return 0; }

    • A.

      5

    • B.

      10

    • C.

      15

    • D.

      It will return some random number

    Correct Answer
    D. It will return some random number
    Explanation
    The given code declares an array of integer pointers called "arr" and initializes it with the addresses of variables a, b, and c. When arr[1] is printed, it will return the value stored at the memory address pointed to by arr[1], which is the address of variable b. Therefore, the output will be the value of variable b, which is 10.

    Rate this question:

  • 43. 

    Which of the following type of class allows only one object of it to be created?

    • A.

      Virtual class

    • B.

      Abstract class

    • C.

      Singleton class

    • D.

      Friend class

    Correct Answer
    C. Singleton class
    Explanation
    A singleton class allows only one object of it to be created. This is achieved by making the constructor of the class private, so that it cannot be accessed from outside the class. The class provides a static method that returns the instance of the class, and this method is responsible for creating the object if it doesn't exist already. This ensures that only one instance of the class can be created and accessed throughout the program.

    Rate this question:

  • 44. 

    Can we typecast void into int?

    • A.

      Yes

    • B.

      No

    • C.

      Undefined

    • D.

      Depends on Compiler

    Correct Answer
    A. Yes
    Explanation
    Yes, we can typecast void into int. Typecasting is a way to convert one data type into another. However, since void represents the absence of a type, it cannot hold any value. So, when we typecast void into int, it will result in an undefined or garbage value.

    Rate this question:

  • 45. 

    What is the type of variable ‘b’ and ‘d’ in the below snippet? int a[], b; int []c, d;

    • A.

      ‘b’ and ‘d’ are int

    • B.

      ‘b’ and ‘d’ are arrays of type int

    • C.

      ‘b’ is int variable; ‘d’ is int array

    • D.

      ‘d’ is int variable; ‘b’ is int array

    Correct Answer
    C. ‘b’ is int variable; ‘d’ is int array
    Explanation
    The variable 'b' is declared as an int variable, while the variable 'd' is declared as an int array.

    Rate this question:

  • 46. 

    BOSS is developed by ________

    • A.

      NSDL

    • B.

      C-DAC

    • C.

      NCL

    • D.

      NASA

    Correct Answer
    B. C-DAC
    Explanation
    BOSS (Bharat Operating System Solutions) is an operating system developed by C-DAC (Centre for Development of Advanced Computing). C-DAC is an Indian research and development organization that specializes in the design and development of advanced computing technologies. They have expertise in areas such as high-performance computing, software development, and networking. C-DAC's involvement in the development of BOSS makes them the correct answer for this question.

    Rate this question:

  • 47. 

    What is size of generic pointer in C++ (in 32-bit platform) ?

    • A.

      2

    • B.

      4

    • C.

      8

    • D.

      0

    Correct Answer
    B. 4
    Explanation
    In a 32-bit platform, the size of a generic pointer in C++ is 4 bytes. This is because a generic pointer is used to store memory addresses, and in a 32-bit platform, memory addresses are typically represented using 32 bits or 4 bytes.

    Rate this question:

  • 48. 

    What will be the output of the following code?      int a=36,b=9;      printf(“%d”,a>>a/b-2);

    • A.

      9

    • B.

      7

    • C.

      5

    • D.

      None of these

    Correct Answer
    A. 9
    Explanation
    The code first performs the division operation `a/b`, which results in 4. Then, it performs the right shift operation `a>>4`, which shifts the bits of 36 four positions to the right, resulting in 2. Finally, it subtracts 2 from 2, resulting in 0. The `printf` statement then outputs the value 0.

    Rate this question:

  • 49. 

    What will be the output of the following code?      main()       {           int x=15;           printf(“\n%d%d%d”,x!=15,x=20,x<30);      }

    • A.

      0 20 1

    • B.

      15 20 30

    • C.

      1 20 1

    • D.

      ERROR

    Correct Answer
    C. 1 20 1
    Explanation
    The output of the code will be "1 20 1". This is because the code uses the printf function to print three values: x!=15, x=20, and x

    Rate this question:

  • 50. 

    Which reference modifier is used to define reference variable?

    • A.

      &

    • B.

      *

    • C.

      #

    • D.

      None of these

    Correct Answer
    A. &
    Explanation
    The reference modifier "&" is used to define a reference variable.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 19, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 06, 2019
    Quiz Created by
    Hrithik
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.