Q. Find the output of the following program.

Code:
main(){
 char ch[] = “Interviewbit Scaler”; 
 int l = strlen(ch);
 cout << l << endl;
}
  • (A) 18
  • (B) 19
  • (C) 20
  • (D) 21
πŸ’¬ Discuss
βœ… Correct Answer: (B) 19

Q. Find the output of the following program.

Code:
main(){
 int i = (1, 2, 3);
 cout << i << endl;
}
  • (A) 1
  • (B) 2
  • (C) 3
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 3

Q. Which of the following is the correct identifier?

  • (A) 2var_name
  • (B) 2VAR_NAME
  • (C) $varname
  • (D) var_name12
πŸ’¬ Discuss
βœ… Correct Answer: (D) var_name12

Q. Which of the following is not a type of inheritance?

  • (A) Multiple
  • (B) Multilevel
  • (C) Distributed
  • (D) Heirarchical
πŸ’¬ Discuss
βœ… Correct Answer: (C) Distributed

Q. What is an object in c++?

  • (A) It is function of class
  • (B) It is instance of class
  • (C) It is datatype of class
  • (D) It is part of the syntax of class
πŸ’¬ Discuss
βœ… Correct Answer: (B) It is instance of class

Q. Choose the right option

Code:
string* p, q;
  • (A) q is a pointer to a string, p is a string
  • (B) both p and q are pointers to string types
  • (C) p is a pointer to a string, q is a string
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (C) p is a pointer to a string, q is a string

Q. The operator used for dereferencing or indirection is ____

  • (A) –>>
  • (B) &
  • (C) *
  • (D) ->
πŸ’¬ Discuss
βœ… Correct Answer: (C) *

Q. Identify the incorrect statements.

Code:
 int num = 23;
Statement (i):   int *ptr = &(num + 2);
Statement (ii):  int *ptr2 = #
Statement (iii): &&num = 50;
  • (A) Statement (ii) and (iii) are wrong
  • (B) Statement (i) and (iii) are wrong
  • (C) Statement (i) and (ii) are wrong
  • (D) All the three are wrong
πŸ’¬ Discuss
βœ… Correct Answer: (B) Statement (i) and (iii) are wrong

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        int p = 15;
        if (p < 13) {
            for (k = 0; k < 12; k++)
               cout << k;
        }
        else {
            cout << k;
        }
        return 0;
    }
  • (A) Compilation Error
  • (B) Runtime Error
  • (C) Garbage Value
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Compilation Error

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    void Output()
    {
        static int p = 1;
        int k;
        for(k=p; k<=3; k++)
        {
        p++;
        cout << p;
        }
    }
    int main()
    {
        Output();
        Output();
        Output();
        return 0;
    }
  • (A) 0123
  • (B) 123
  • (C) 234
  • (D) 012345
πŸ’¬ Discuss
βœ… Correct Answer: (C) 234