Q. Can two functions declare variables(non static) with the same name.

  • (A) Yes
  • (B) No
  • (C) No, it gives a runtime error
  • (D) Yes, but not a very efficient way to write programs
πŸ’¬ Discuss
βœ… Correct Answer: (D) Yes, but not a very efficient way to write programs

Q. Pick the right option
Statement (i) Global values are not initialized by the stream.
Statement (ii) Local values are implicitly initialised to 0.

  • (A) Statement (i) is true, Statement (i) is false
  • (B) Statement (i) is true, Statement (ii) is false
  • (C) Both are true
  • (D) Both are false
πŸ’¬ Discuss
βœ… Correct Answer: (D) Both are false

Q. Which of the given statements are false.
(i). extern int func;
(ii). extern int func2(int,int);
(iii). int func2(int,int);
(iv). extern class foo;

  • (A) (ii), (iii) and (iv)
  • (B) (iii) and (iv) only
  • (C) (ii) and (iii) only
  • (D) only (iv)
πŸ’¬ Discuss
βœ… Correct Answer: (D) only (iv)

Q. Pick the right option
Statement (i) A definition is also a declaration.
Statement (ii) An identifier can be declared just once.

  • (A) Statement (ii) is true, Statement (i) is false
  • (B) Statement (i) is true, Statement (ii) is false
  • (C) Both are true
  • (D) Both are false
πŸ’¬ Discuss
βœ… Correct Answer: (A) Statement (ii) is true, Statement (i) is false

Q. Choose the correct option.
(i) extern int k;
(ii) int k;

  • (A) (i) declares and defines k, (ii) declares k
  • (B) both (i) and (ii) declare k
  • (C) (i) declares k, (ii) declares and defines k
  • (D) (i) declares the variable k and (ii) defines k
πŸ’¬ Discuss
βœ… Correct Answer: (C) (i) declares k, (ii) declares and defines k

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        int k;
        enum Month {
            January = 1, February ,March, April, May, June, July, August, September, October, November, December
        };
        for (k = April; k <= September; k++)
            cout << k;
        return 0;
    }
  • (A) 456789
  • (B) 0123456789101112
  • (C) 0123456
  • (D) 89101112
πŸ’¬ Discuss
βœ… Correct Answer: (A) 456789

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        enum channel {hotstar, zeetv, max};
        enum symbol {anamol, hotstar};
        int k = 0;
        for (k = hotstar; k <= zeetv; k++) {
           cout << k;
        }
        return 0;
    }
  • (A) Compilation Error
  • (B) Runtime Error
  • (C) Garbage Value
  • (D) hotstar
πŸ’¬ Discuss
βœ… Correct Answer: (A) Compilation Error

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    enum Gender {
        male, female, transgender
    };
    int main()
    {
        cout << male<< female<< transgender;
        return 0;
    }
  • (A) male
  • (B) female
  • (C) transgender
  • (D) 012
πŸ’¬ Discuss
βœ… Correct Answer: (D) 012

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    enum test 
    {
        p = 20, q, r
    };
    int main()
    {
        cout << p <<" " << q<< " " << r;
        return 0;
    }
  • (A) 20 21
  • (B) 21 22
  • (C) 20 21 22
  • (D) 20 22
πŸ’¬ Discuss
βœ… Correct Answer: (C) 20 21 22

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    enum  boy
    {
        num = 20
    };
    int main()
    {
        int age = 100;
        age /= num;
        cout << "If you were boy, you would be " << age << endl;
        return 0;
    }
  • (A) If you were boy, you would be 5
  • (B) If you were boy, you would be 0
  • (C) If you were boy, you would be 10
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (A) If you were boy, you would be 5