πŸ“Š C++
Q. What is the output of this program?
Code:
#include <iostream>
    #include <iomanip>
    using namespace std;
    void showDate(int mm, int dd, int yy)
    {
        cout << setfill('0');
        cout << setw(2) << mm << '/'
        << setw(2) << dd << '/'
        << setw(4) << yy << endl;
    }
    int main()
    {
        showDate(1, 1, 2019);
        return 0;
    }
  • (A) 01
  • (B) 02
  • (C) 2019
  • (D) 01/01/2019
πŸ’¬ Discuss
βœ… Correct Answer: (D) 01/01/2019
πŸ“Š C++
Q. Which function allows you to set minimum width for the next input?
  • (A) setwidth
  • (B) setfill
  • (C) setw
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (C) setw
πŸ“Š C++
Q. Choose the correct formatted code.
  • (A) int main() { cout << 10;}
  • (B) int main(){ cout << “10”}
  • (C) int main() { cout << “10”; }
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (C) int main() { cout << “10”; }
πŸ“Š C++
Q. What is the use of the indentation in c++?
  • (A) r distinguishes between comments and outer data
  • (B) distinguishes between comments and code
  • (C) both a and b
  • (D) to write multi line comment in c++
πŸ’¬ Discuss
βœ… Correct Answer: (B) distinguishes between comments and code
πŸ“Š C++
Q. What is the output of this program?
Code:
#include 
    using namespace std;
    long fact (long p)
    {
        if (p > 1)
            return (p * fact (p + 1));
        else
            return (1);
    }
    int main ()
    {
        long n = 6;
        cout << n << "! = " << fact ( n );
        return 0;
    }
  • (A) 1
  • (B) 6
  • (C) segmentation fault
  • (D) compile time error
πŸ’¬ Discuss
βœ… Correct Answer: (C) segmentation fault
πŸ“Š C++
Q. What is the output of this program?
Code:
#include 
    using namespace std;
    void square (int *p)
    {
	*p = (*p + 3) * (*p);
    }
    int main ( )
    {
	int n = 15;
        square(&n);
	cout << n;
	return 0;
    }
  • (A) 207
  • (B) 270
  • (C) 15
  • (D) 3
πŸ’¬ Discuss
βœ… Correct Answer: (B) 270
πŸ“Š C++
Q. What is the output of this program?
Code:
#include 
    using namespace std;
    int add(int p, int q);
    int main()
    {
        int k = 7, L = 9;
        cout << add(k, L) << endl;
        return 0;
    }
    int add(int p, int q )
    {
        int sum = p + q;
        p = 10;
        return p + q;
    }
  • (A) 7
  • (B) 9
  • (C) 10
  • (D) 19
πŸ’¬ Discuss
βœ… Correct Answer: (D) 19
πŸ“Š C++
Q. What is used to write multi line comment in c++?
  • (A) /$ …. $/
  • (B) //
  • (C) /* …. */
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (C) /* …. */
πŸ“Š C++
Q. What is the output of this program?
Code:
#include 
    using namespace std;
    int main()
    {
        /* this is comment*\
        cout << "Uday";
        return 0;
    }
  • (A) Uday
  • (B) Compilation Error
  • (C) Runtime Error
  • (D) Garbage value
πŸ’¬ Discuss
βœ… Correct Answer: (B) Compilation Error
πŸ“Š C++
Q. What type of comments does c++ support?
  • (A) multiline
  • (B) single line
  • (C) multi-line and single line
  • (D) All of above
πŸ’¬ Discuss
βœ… Correct Answer: (C) multi-line and single line