Question:
What will be the output of the following C# code snippet?
 class test {     public   int a;     public  int b;     public  test(int i, int j)     {         a = i;         b = j;     }     public void meth(test o)     {         o.a *= 2;         o.b /= 2;     } }     class Program {     static void Main(string[] args)     {         test obj = new test(10, 20);         obj.meth(obj);         Console.WriteLine(obj.a + " " + obj.b);             Console.ReadLine();     } }

Choices:
- 20, 40
- 40, 20
- 20, 10
- 10, 20


Question:
What does the following C# code set specifies?
public static int Compare(string strA, string strB)

Choices:
- Comparison is case and culture sensitive
- Two strings A and B are compared with each other
- Output is : >0 for (A > B), <0 for (A < B) else ‘0’ for(A=B)
- All of the mentioned


Question:
What will be the output of the following C# code snippet?
static void Main(string[] args){    string s1 = "Hello" + "c" + "Sharp";    Console.WriteLine(s1);    Console.ReadLine();}

Choices:
- Hello c Sharp
- HellocSharp
- Compile time error
- Hello


Question:
What does the following C# code set specify?
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase)

Choices:
- Comparison begins at strA[indexA] and strB[indexB] and runs for length of characters
- Returns output > 0 for for strA > strB else < 0 for strA < strB else if strA = str B output is 0
- Comparison is culture sensitive and if ignore case is true, comparison ignores case differences
- All of the mentioned


Question:
Which string operation does the below-mentioned method define?
public static string Concat(string str0, string str1)

Choices:
- method returns a string
- string str1 is concatenated to the end of str0
- can be used to concatenate any number of strings
- all of the mentioned


Question:
What will be the output of the following C# code snippet?
static void Main(string[] args){    string s1 = " Ixg";    string s2 = s1.Insert(3,"i");    string s3 = s2.Insert(5, "o");    for (int i = 0; i < s3.Length; i++)    Console.WriteLine(s3[i]);    Console.ReadLine();}

Choices:
- Ixgo
- Ixig
- Ixigo
- Ixg


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         char []chars = {'a', 'b', 'c'};         String s = new String(chars);         Console.WriteLine(s);         Console.ReadLine();     } }

Choices:
- a
- b
- c
- abc


Question:
What will be the output of given code snippet?
 class Program {     static void Main(string[] args)     {         char []chars = {'a', 'b', 'c'};         String s = new String(chars);         String s1 = "abcd";         int len1 = s1.Length;         int len2 = s.Length;         Console.WriteLine(len1 + " " + len2);         Console.ReadLine();     } }

Choices:
- 4 0
- 3 0
- 3 4
- 4 3


Question:
What will be the output of the following C# code snippet?
 class A {     int i;     int j;     public A()     {         i = 1;         j = 2;     } } class Program {     static void Main(string[] args)     {         A obj1 = new A();	 Console.WriteLine(obj1.ToString());         Console.ReadLine();     } }

Choices:
- True
- False
- String associated with obj1
- Compile time error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         String c = "Hello i love Csharp";         Boolean var;	 var = c.StartsWith("hello");         Console.WriteLine(var);         Console.ReadLine();     } }

Choices:
- True
- False
- 1
- Run time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        String s1 = "Hello i love Csharp";        StringBuilder s2 = new  StringBuilder(s1);        Console.WriteLine(s1.Equals(s2));        Console.ReadLine();    }}

Choices:
- True
- False
- 0
- Compile time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        String s1 = "one";        String s2 = string.Concat(s1 + " " + "two");        Console.WriteLine(s2);        Console.ReadLine();    }}

Choices:
- one
- two
- one two
- two one


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        String c = "  Hello World  ";        String s = c.Trim();        Console.WriteLine("""+s+""");        Console.ReadLine();    }}

Choices:
- ” Hello World ”
- “HelloWorld”
- “Hello World”
- “Hello”


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         String s1 = "CSHARP";         String s2 = s1.Replace('H','L');         Console.WriteLine(s2);         Console.ReadLine();     } }

Choices:
- CSHAP
- CSHP
- CSHALP
- CSHP


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         String s1 = "Hello World";         String s2 = s1.Substring(0, 4);         Console.WriteLine(s2);         Console.ReadLine();     } }

Choices:
- Hello
- Hell
- H
- Hello World


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         String s = "Hello World";         int i = s.IndexOf('o');         int j = s.LastIndexOf('l');         Console.WriteLine(i + " " + j);         Console.ReadLine();     } }

Choices:
- 9 5
- 4 9
- 9 0
- 9 4


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {         String c = "i love Csharp";        bool a;        a = c.StartsWith("I");        Console.WriteLine(a);        Console.ReadLine();    }}

Choices:
- true
- false
- 0
- 1


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {         String []chars = {"z", "x", "y", "z", "y"};        for (int i = 0; i < chars.Length; ++i)        for (int j = i + 1; j < chars.Length; ++j)        if(chars[i].CompareTo(chars[j]) == 0)        Console.WriteLine(chars[j]);        Console.ReadLine();    }}

Choices:
- zx
- xy
- zy
- yz


Question:
What will be the output of the following C# code snippet?
 static void main(String args[]) {     char chars[] = {'a', 'b', 'c'};     String s = new String(chars);     Console.WriteLine(s); }

Choices:
- a
- b
- ab
- abc


Question:
What will be the output of the following C# code snippet?
 static void Main(string[] args) {     string s = " i love you";     Console.WriteLine(s.IndexOf('l') + "  " + s.lastIndexOf('o') + "  " + s.IndexOf('e'));     Console.ReadLine(); }

Choices:
- 3 5 7
- 4 5 6
- 3 9 6
- 2 4 6


Question:
Which of the following feature of OOPs is not used in the following C++ code?
class A
{
    int i;
    public:
    void print(){cout<<"hello"<<i;}
}

class B: public A
{
    int j;
    public:
    void assign(int a){j = a;}
}

Choices:
- Abstraction
- Encapsulation
- Inheritance
- Polymorphism


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A{
public:
	A(){
		cout<<"Constructor called\n";
	   }
	~A(){
		cout<<"Destructor called\n";
	    }
};
int main(int argc, char const *argv[])
{
	A *a = new A[5];
	delete a;
	return 0;
}

Choices:
- “Constructor called” five times and then “Destructor called” five times
- “Constructor called” five times and then “Destructor called” once
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A{
public:
	A(){
		cout<<"Constructor called\n";
	   }
	~A(){
		cout<<"Destructor called\n";
	    }
};
int main(int argc, char const *argv[])
{
	A *a = new A[5];
	delete[] a;
	return 0;
}

Choices:
- “Constructor called” five times and then “Destructor called” five times
- “Constructor called” five times and then “Destructor called” once
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;

class A
{
   int a;
   A() { a = 5;}
};

int main()
{
    A *obj = new A;
    cout << obj->a;
}

Choices:
- 5
- Garbage value
- Compile-time error
- Run-time error


Question:
What happens if the following C++ statement is compiled and executed?
int *ptr = NULL;
delete ptr;

Choices:
- The program compiled successfully but throws an error during run-time
- The program gives a compile-time error
- The program is not semantically correct
- The program is compiled and executed successfully


Question:
What happens if a pointer is deleted twice in a program as shown in the following C++ statements?
int *ptr = new int;
delete ptr;
delete ptr;

Choices:
- Undefined behaviour
- Syntactically incorrect
- Semantically incorrect
- The program runs perfectly


Question:
What happens if the following program is executed in C and C++?
#include<stdio.h>
int main()
{
   foo();
}
int foo()
{
   printf("Hello");
   return 0;
}

Choices:
- Error in both C and C++
- Warning in both C and C++
- Error in C++ but Warning in C
- Error in C but Warning in C++


Question:
What happens if the following program is executed in C and C++?
#include <stdio.h>
int main(void)
{
	const int j = 20;
	int *ptr = &j;
	printf("*ptr: %d\n", *ptr);
	return 0;
}

Choices:
- Error in both C and C++
- Warning in both C and C++
- Error in C but Warning in C++
- Error in C++ but Warning in C


Question:
What happens if the following line is executed in C and C++?
int *p = malloc(10);

Choices:
- Error in both C and C++
- Warning in both C and C++
- Error in C++ and successful execution in C
- Error in C and successful execution in C++


Question:
What happens if the following line is executed in C and C++?
const int a;

Choices:
- Error in both C and C++
- Warning in both C and C++
- Error in C and successful execution in C++
- Error in C++ and successful execution in C


Question:
What happens if the following program is executed in C and C++?
#include <stdio.h>
int main(void)
{
	int new = 5;
	printf("%d", new);
}

Choices:
- Error in both C and C++
- A successful run in both C and C++
- Error in C and successful execution in C++
- Error in C++ and successful execution in C


Question:
What happens if the following program is executed in C and C++?
#include <stdio.h>
void main()
{
	printf("Hello World");
}

Choices:
- Error in both C and C++
- Successful run in both C and C++
- Error in C and successful execution in C++
- Error in C++ and successful execution in C


Question:
What happens if the following program is executed in C and C++?
#include <stdio.h>
void func(void)
{
	printf("Hello");
}
void main()
{
	func();
	func(2);
}

Choices:
- Error in both C and C++
- Outputs Hello twice in both C and C++
- Error in C and successful execution in C++
- Error in C++ and successful execution in C


Question:
What happens if the following program is executed in C and C++?
#include <stdio.h>
void func()
{
	printf("Hello");
}
void main()
{
	func();
	func(2);
}

Choices:
- Error in both C and C++
- Outputs Hello twice in both C and C++
- Error in C and Outputs Hello twice in C++
- Error in C++ and Outputs Hello twice in C


Question:
What will be the output of the following program in both C and C++?
#include<stdio.h>
int main(int argc, char const *argv[])
{
	printf("%d\n", (int)sizeof('a'));
	return 0;
}

Choices:
- Output in C is 1 and in C++ is 4
- Output in C is 4 and in C++ is 1
- Output in C is 1 and in C++ is 1
- Output in C is 4 and in C++ is 4


Question:
What will be the output of the following C++ code?
#include<stdio.h>
int main(int argc, char const *argv[])
{
	char a = 'a';
	printf("%d\n", (int)sizeof(a));
	return 0;
}

Choices:
- Output in C is 1 and in C++ is 4
- Output in C is 4 and in C++ is 1
- Output in C is 1 and in C++ is 1
- Output in C is 4 and in C++ is 4


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int x = 1;
int main()
{
    int x = 2;
    {
        int x = 3;
        cout << ::x << endl;
    }
    return 0;
}

Choices:
- 1
- 2
- 3
- 123


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
class A
{
  ~A(){
    cout<<"Destructor called\n";
  }
};
int main()
{
    A a;
    return 0;
}

Choices:
- Destructor called
- Nothing will be printed
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int x[100];
int main()
{
    cout << x[99] << endl;
}

Choices:
- Garbage value
- 0
- 99
- Error


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int main ()
{
   int cin;
   cin >> cin;
   cout << "cin: " << cin;
   return 0;
}

Choices:
- cin: garbage value
- Error
- Segmentation fault
- Nothing is printed


Question:
What happens if we run the following code in both C and C++?
#include<stdio.h>
struct STRUCT
{
  int a;
  int func()
  {
      printf("HELLO THIS IS STRUCTURE\n");
  }
};
int main()
{
  struct STRUCT s;
  s.func();
  return 0;
}

Choices:
- The program runs fine and both prints output “HELLO THIS IS STRUCTURE”
- The program gives an error in case of C but runs perfectly in case of C++
- The program gives an error in case of C++ but runs perfectly in case of C
- The program gives an error in case of both C and C++


Question:
What happens if we run the following code in both C and C++?
#include<stdio.h>
struct STRUCT
{
  int a = 5;
  int func()
  {
      printf("%d\n", a);
  }
};
int main()
{
  struct STRUCT s;
  s.func();
  return 0;
}

Choices:
- The program runs fine and both prints output “HELLO THIS IS STRUCTURE”
- The program gives an error in case of C but runs perfectly in case of C++
- The program gives an error in case of C++ but runs perfectly in case of C
- The program gives an error in case of both C and C++


Question:
What happens if the following program is compiled in both C and C++?
#include<stdio.h>
struct STRUCT
{
  int static a;
};
int main()
{
  struct STRUCT s;
  return 0;
}

Choices:
- The program runs fine and both prints output “HELLO THIS IS STRUCTURE”
- The program gives an error in case of C but runs perfectly in case of C++
- The program gives an error in case of C++ but runs perfectly in case of C
- The program gives an error in case of both C and C++


Question:
What happens if the following code is compiled on both C and C++?
#include<stdio.h>
struct STRUCT
{
private:
	int a;
};
int main()
{
	printf("%d\n", (int)sizeof(struct STRUCT));
	return 0;
}

Choices:
- The program runs fine and both prints output “HELLO THIS IS STRUCTURE”
- The program gives an error in case of C but runs perfectly in case of C++
- The program gives an error in case of C++ but runs perfectly in case of C
- The program gives an error in case of both C and C++


Question:
What will be the output of the following C++ code?
#include <iostream>

int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}

Choices:
- Hello World
- Compile-time error
- Run-time error
- Segmentation fault


Question:
Which of the following C++ code will give error on compilation?
================code 1=================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}
========================================
================code 2=================
#include <iostream>
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
========================================

Choices:
- Both code 1 and code 2
- Code 1 only
- Code 2 only
- Neither code 1 nor code 2


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Test
{
    static int x;
  public:
    Test() { x++; }
    static int getX() {return x;}
};
int Test::x = 0;
int main()
{
    cout << Test::getX() << " ";
    Test t[5];
    cout << Test::getX();
}

Choices:
- 0 0
- 5 0
- 0 5
- 5 5


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Player
{
  private:
    int id;
    static int next_id;
  public:
    int getID() { return id; }
    Player()  {  id = next_id++; }
};
int Player::next_id = 1;
int main()
{
  Player p1;
  Player p2;
  Player p3;
  cout << p1.getID() << " ";
  cout << p2.getID() << " ";
  cout << p3.getID();
  return 0;
}

Choices:
- 1 2 3
- 2 2 2
- 1 3 1
- 1 1 1


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A
{
   private:
     int x;
   public:
     A(int _x)  {  x = _x; }
     int get()  { return x; }
};
class B
{
    static A a;
  public:
   static int get()
   {  return a.get(); }
};
int main(void)
{
    B b;
    cout << b.get();
    return 0;
}

Choices:
- Garbage value
- Compile-time Error
- Run-time Error
- Nothing is printed


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
class Test
{
   private:
     static int count;
   public:
     Test& fun();
};
int Test::count = 0;
Test& Test::fun()
{
    Test::count++;
    cout << Test::count << " ";
    return *this;
}
int main()
{
    Test t;
    t.fun().fun().fun().fun();
    return 0;
}

Choices:
- 4 4 4 4
- 1 2 3 4
- 1 1 1 1
- 0 1 2 3


Question:
What will be the output of the following C++ code?
#include <iostream>
class Test
{
   public:
     void fun();
};
static void Test::fun()
{
    std::cout<<"fun() is static";
}
int main()
{
    Test::fun();
    return 0;
}

Choices:
- fun() is static
- Compile-time Error
- Run-time Error
- Nothing is printed


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Point
{
    int x, y;
  public:
   Point(int i = 0, int j =0)
   { x = i; y = j;  }
   int getX() const { return x; }
   int getY() {return y;}
};

int main()
{
    const Point t;
    cout << t.getX() << " ";
    cout << t.gety();
    return 0;
}

Choices:
- 0 0
- Garbage values
- Compile error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <stdio.h>
int main()
{
   const int x;
   x = 10;
   printf("%d", x);
   return 0;
}

Choices:
- 10
- Garbage value
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
int const s=9;
int main()
{
    std::cout << s;
    return 0;
}

Choices:
- 9
- Garbage value
- Error
- Segmentation fault


Question:
Which of the following statements are true?
int f(float)

Choices:
- f is a function taking an argument of type int and returning a floating point number
- f is a function taking an argument of type float and returning an integer
- f is a function of type float
- f is a function of type int


Question:
What is the value of the bool?
bool is_int(789.54)

Choices:
- True
- False
- 1
- 2


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int f(int p, int q)    {        if (p > q)            return p;        else            return q;    }    main()    {        int a = 5, b = 10;        int k;        bool x = true;        bool y = f(a, b);        k =((a * b) + (x + y));        cout << k;    }

Choices:
- 55
- 62
- 52
- 75


Question:
What is the value of p in the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int p;        bool a = true;        bool b = false;        int x = 10;        int y = 5;        p = ((x | y) + (a + b));        cout << p;        return 0;    }

Choices:
- 0
- 16
- 12
- 2


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        char c = 74;        cout << c;        return 0;    }

Choices:
- A
- N
- J
- I


Question:
What will be the output of the following C++ code?
    #include <stdio.h>    int main()    {        char a = '\012';         printf("%d", a);        return 0;    }

Choices:
- Compiler error
- 12
- 10
- Empty


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {    	int x = -1;        unsigned int y = 2;         if(x > y)         {        	cout << "x is greater";    	}        else         {    		cout << "y is greater";    	}          }

Choices:
- x is greater
- y is greater
- implementation defined
- arbitrary


Question:
What is the value of the following 8-bit integer after all statements are executed?
int x = 1;x = x << 7;x = x >> 7;

Choices:
- 1
- -1
- 127
- Implementation defined


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 8;        cout << "ANDing integer 'a' with 'true' :" << a && true;        return 0;    }

Choices:
- ANDing integer ‘a’ with ‘true’ :8
- ANDing integer ‘a’ with ‘true’ :0
- ANDing integer ‘a’ with ‘true’ :1
- ANDing integer ‘a’ with ‘true’ :9


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int i = 3;        int l = i / -2;        int k = i % -2;        cout << l << k;        return 0;    }

Choices:
- compile time error
- -1 1
- 1 -1
- implementation defined


Question:
What will be the output of the following C++ function?
    int main()    {        register int i = 1;        int *ptr = &i;        cout << *ptr;	return 0;    }

Choices:
- 0
- 1
- Compiler error may be possible
- Runtime error may be possible


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        float num1 = 1.1;        double num2 = 1.1;        if (num1 == num2)           cout << "stanford";        else           cout << "harvard";        return 0;    }

Choices:
- harvard
- stanford
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iomanip>    #include <iostream>    using namespace std;    int main()    {        cout << setprecision(17);        double d = 0.1;        cout << d << endl;        return 0;    }

Choices:
- 0.11
- 0.10000000000000001
- 0.100001
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        float i = 123.0f;        cout << i << endl;        return 0;    }

Choices:
- 123.00
- 1.23
- 123
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        float f1 = 0.5;        double f2 = 0.5;        if (f1 == 0.5f)            cout << "equal";        else            cout << "not equal";        return 0;    }

Choices:
- equal
- not equal
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int num = 0x20 + 020 + 20;        cout << sizeof(num)<<'\n';        return 0;    }

Choices:
- 2
- 4
- Depends on compiler
- Garbage


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

Choices:
- 4
- 2
- 8
- garbage


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

Choices:
- 2
- 4
- 8
- garbage


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 5;        float b;        cout << sizeof(++a + b);        cout << a;        return 0;    }

Choices:
- 2 6
- 4 6
- 2 5
- 4 5


Question:
What will be the output of the following C++ code (in 32-bit systems)?
    #include <iostream>    using namespace std;    int main()    {        cout << sizeof(char);        cout << sizeof(int);        cout << sizeof(float);        return 0;    }

Choices:
- 1 4 4
- 1 4 8
- 1 8 8
- 1 8 2


Question:
What does the following statement mean?
void a;

Choices:
- variable a is of type void
- a is an object of type void
- declares a variable with value a
- flags an error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        void a = 10, b = 10;        int c;        c = a + b;        cout << c;        return 0;    }

Choices:
- 20
- compile time error
- runtime error
- 40


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    enum  cat     {        temp = 7    };    int main()    {        int age = 14;        age /= temp;        cout << "If you were cat, you would be " << age << endl;        return 0;    }

Choices:
- If you were cat, you would be 5
- If you were cat, you would be 2
- If you were cat, you would be 7
- If you were cat, you would be 9


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    enum test     {        A = 32, B, C    };    int main()    {        cout << A << B<< C;        return 0;    }

Choices:
- 323334
- 323232
- 323130
- 323134


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    enum colour     {        green, red, blue, white, yellow, pink    };    int main()    {        cout << green<< red<< blue<< white<< yellow<< pink;        return 0;    }

Choices:
- 012345
- 123456
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        enum channel {star, sony, zee};        enum symbol {hash, star};        int i = 0;        for (i = star; i <= zee; i++)         {            printf("%d ", i);        }        return 0;    }

Choices:
- 012
- 123
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int i;        enum month         {            JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC        };        for (i = MAR; i <= NOV; i++)            cout << i;        return 0;    }

Choices:
- 01234567891011
- 123456789101112
- 34567891011
- 123456789


Question:
Choose the correct option.
    extern int i;
    int i;

Choices:
- both 1 and 2 declare i
- 1 declares the variable i and 2 defines i
- 1 declares and defines i, 2 declares i
- 1 declares i,2 declares and defines i


Question:
Pick the right option.
Statement 1: A definition is also a declaration.
Statement 2: An identifier can be declared just once.

Choices:
- Statement 1 is true, Statement 2 is false
- Statement 2 is true, Statement 1 is false
- Both are false
- Both are true


Question:
Pick the right option.
Statement 1: Global values are not initialized by the stream.
Statement 2: Local values are implicitly initialised to 0.

Choices:
- Statement 1 is true, Statement 2 is false
- Statement 2 is true, Statement 1 is false
- Both are false
- Both are true


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int g = 100;    int main()    {        int a;        {            int b;            b = 20;            a = 35;            g = 65;           cout << b << a << g;        }        a = 50;        cout << a << g;        return 0;    }

Choices:
- 2035655065
- 2035655035
- 2035635065
- 2035645065


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void addprint()    {        static int s = 1;        s++;        cout << s;    }    int main()    {        addprint();        addprint();        addprint();        return 0;    }

Choices:
- 234
- 111
- 123
- 235


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 10;        if (a < 10)         {            for (i = 0; i < 10; i++)               cout << i;        }        else         {            cout << i;        }        return 0;    }

Choices:
- 0123456789
- 123456789
- 0
- error


Question:
Identify the incorrect statements.
    int var = 10;
    int *ptr = &(var + 1); //statement 1
    int *ptr2 = &var; //statement 2
    &&var = 40; //statement 3

Choices:
- Statement 1 and 2 are wrong
- Statement 2 and 3 are wrong
- Statement 1 and 3 are wrong
- Statement 1, 2 and 3 are wrong


Question:
Identify the type of variables.
    typedef char* CHAR;
    CHAR p,q;

Choices:
- char*
- char
- CHAR
- unknown


Question:
What does the following statement mean?
int (*fp)(char*)

Choices:
- pointer to a pointer
- pointer to an array of chars
- pointer to function taking a char* argument and returns an int
- function taking a char* argument and returning a pointer to int


Question:
What will happen in the following C++ code snippet?
   int a = 100, b = 200;   int *p = &a, *q = &b;   p = q;

Choices:
- b is assigned to a
- p now points to b
- a is assigned to b
- q now points to a


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 5, b = 10, c = 15;        int *arr[ ] = {&a, &b, &c};        cout << arr[1];        return 0;    }

Choices:
- 5
- 10
- 15
- it will return some random number


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        char arr[20];        int i;        for(i = 0; i < 10; i++)            *(arr + i) = 65 + i;        *(arr + i) = '\0';        cout << arr;        return(0);    }

Choices:
- ABCDEFGHIJ
- AAAAAAAAAA
- JJJJJJJJ
- AAAAAAJJJJ


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        char *ptr;        char Str[] = "abcdefg";        ptr = Str;        ptr += 5;        cout << ptr;        return 0;    }

Choices:
- fg
- cdef
- defg
- abcd


Question:
What will be the output of the following C++ code?
    #include <stdio.h>    #include<iostream>    using namespace std;    int array1[] = {1200, 200, 2300, 1230, 1543};    int array2[] = {12, 14, 16, 18, 20};    int temp, result = 0;    int main()    {        for (temp = 0; temp < 5; temp++)         {            result += array1[temp];        }        for (temp = 0; temp < 4; temp++)        {            result += array2[temp];        }        cout << result;        return 0;    }

Choices:
- 6553
- 6533
- 6522
- 12200


Question:
What will be the output of the following C++ code?
    #include <stdio.h>    #include<iostream>    using namespace std;    int main ()    {        int array[] = {0, 2, 4, 6, 7, 5, 3};        int n, result = 0;        for (n = 0; n < 8; n++)         {            result += array[n];        }        cout << result;        return 0;    }

Choices:
- 25
- 26
- 27
- 21


Question:
What will be the output of the following C++ code?
    #include <stdio.h>    #include<iostream>    using namespace std;    int main()    {        int a = 5, b = 10, c = 15;        int arr[3] = {&a, &b, &c};        cout << *arr[*arr[1] - 8];        return 0;    }

Choices:
- 15
- 18
- garbage value
- compile time error


Question:
What will be the output of the following C++ code?
    #include <stdio.h>    #include <iostream>    using namespace std;    int main()    {        char str[5] = "ABC";        cout << str[3];        cout << str;        return 0;    }

Choices:
- ABC
- ABCD
- AB
- AC


Question:
What will be the output of the following C++ code?
    #include <stdio.h>    #include <iostream>    using namespace std;    int main()    {        int array[] = {10, 20, 30};        cout << -2[array];        return 0;    }

Choices:
- -15
- -30
- compile time error
- garbage value


Question:
What will be the output of the following C++ code?
   #include <iostream>   using namespace std;   int main()   {       int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};       cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];       return 0;   }

Choices:
- 15 18 21
- 21 21 21
- 24 24 24
- Compile time error


Question:
What will be the output of the following C++ code?
   #include <iostream>   using namespace std;   int main()   {       int i;       const char *arr[] = {"C", "C++", "Java", "VBA"};       const char *(*ptr)[4] = &arr;       cout << ++(*ptr)[2];       return 0;   }

Choices:
- ava
- java
- c++
- compile time error


Question:
What will be the output of the following C++ code?
   #include <iostream>   using namespace std;   int main()   {       int arr[] = {4, 5, 6, 7};       int *p = (arr + 1);       cout << *p;       return 0;   }

Choices:
- 4
- 5
- 6
- 7


Question:
What will be the output of the following C++ code?
   #include <iostream>   using namespace std;   int main()   {       int arr[] = {4, 5, 6, 7};       int *p = (arr + 1);       cout << arr;       return 0;   }

Choices:
- 4
- 5
- address of arr
- 7


Question:
What will be the output of the following C++ code?
   #include <iostream>   using namespace std;   int main ()   {       int numbers[5];       int * p;       p = numbers;  *p = 10;       p++;  *p = 20;       p = &numbers[2];  *p = 30;       p = numbers + 3;  *p = 40;       p = numbers;  *(p + 4) = 50;       for (int n = 0; n < 5; n++)           cout << numbers[n] << ",";       return 0;   }

Choices:
- 10,20,30,40,50,
- 1020304050
- compile error
- runtime error


Question:
What will be the output of the following C++ code?
   #include <iostream>   using namespace std;   int main()   {        int arr[] = {4, 5, 6, 7};        int *p = (arr + 1);        cout << *arr + 9;        return 0;   }

Choices:
- 12
- 5
- 13
- error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int  const  p = 5;        cout << ++p;        return 0;    }

Choices:
- 5
- 6
- Error
- 8


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    #define PI 3.14159    int main ()    {        float r = 2;        float circle;        circle = 2 * PI * r;        cout << circle;        return 0;    }

Choices:
- 12.5664
- 13.5664
- 10
- 15


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void swap(int &a, int &b);    int main()    {        int a = 5, b = 10;        swap(a, b);        cout << "In main " << a << b;        return 0;    }    void swap(int &a, int &b)    {        int temp;        temp = a;        a = b;        b = temp;        cout << "In swap " << a << b;    }

Choices:
- In swap 105 In main 105
- In swap 105 In main 510
- In swap 510 In main 105
- In swap 510 In main 510


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 9;        int & aref = a;        a++;        cout << "The value of a is " << aref;        return 0;    }

Choices:
- 9
- 10
- error
- 11


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void print (char * a)    {        cout << a << endl;    }    int main ()    {        const char * a = "Hello world";        print(const_cast<char *> (a) );        return 0;    }

Choices:
- Hello world
- Hello
- world
- compile time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int &q = 5;
	cout<<q;
	return 0;
}

Choices:
- 5
- Run-time error
- Segmentation fault
- Compile-time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int &p;
	int a = 5;
	&p = a;
	cout<<p;
	return 0;
}

Choices:
- 5
- 55
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int a = 5;
	int &p = a;
	cout<<p;
	return 0;
}

Choices:
- 5
- Run-time error
- Segmentation fault
- Compile-time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int a = 5;
	int *p = &a;
	int &q = p;
	cout<<p;
	return 0;
}

Choices:
- 5
- Run-time error
- Segmentation fault
- Compile-time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int a = 5;
	int *p = &a;
	int *(&q) = p;
	cout<<q;
	return 0;
}

Choices:
- 5
- Address of pointer a
- Address of pointer p
- Error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int a = 5;
	int *p = &a;
	int &q = a;
	cout<<p<<endl;
	cout<<q<<endl;
	return 0;
}

Choices:
- Address of a followed by 5 in next line
- Address of p followed by 5 in next line
- Address of a followed by Address of a in next line
- Address of p followed by Address of q in next line


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int a = 5;
	int *p = &a;
	int &q = a;
	cout<<*p<<endl;
	cout<<*q<<endl;
	return 0;
}

Choices:
- Address of a followed by 5 in next line
- Address of p followed by 5 in next line
- Run time error
- Compile time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int &q = NULL;
	cout<<q;
	return 0;
}

Choices:
- NULL
- 0
- Address of NULL
- Error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

void func(const int &a)
{
	int temp = 10;
	a = temp;
	cout<<a;
}

int main(int argc, char const *argv[])
{
	int a = 5;
	func(a);
	return 0;
}

Choices:
- 5
- 10
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int f(int &x, int c)
{
   c  = c - 1;
   if (c == 0) return 1;
   x = x + 1;
   return f(x, c) * x;
}
int main(int argc, char const *argv[])
{
	int a = 4;
	cout<<f(a,a);
	return 0;
}

Choices:
- 343
- 336
- 120
- 840


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;

int &fun()
{
    static int x = 10;
    return x;
}
int main()
{
    fun() = 30;
    cout << fun();
    return 0;
}

Choices:
- 30
- 10
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;

int &fun()
{
    int x = 10;
    return x;
}
int main()
{
    fun() = 30;
    cout << fun();
    return 0;
}

Choices:
- 30
- 10
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int func(void *Ptr);    int main()    {        char *Str = "abcdefghij";        func(Str);        return 0;    }    int func(void *Ptr)    {        cout << Ptr;        return 0;    }

Choices:
- abcdefghij
- address of string “abcdefghij”
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int *p;        void *vp;        if (vp == p);            cout << "equal";        return 0;    }

Choices:
- equal
- no output
- compile error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int i;        char c;        void *data;        i = 2;        c = 'd';        data = &i;        cout << "the data points to the integer value" << data;        data = &c;        cout << "the data now points to the character" << data;        return 0;    }

Choices:
- 2d
- two memory addresses
- 3d
- 4d


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int n = 5;        void *p = &n;        int *pi = static_cast<int*>(p);        cout << *pi << endl;        return 0;    }

Choices:
- 5
- 6
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 5, c;        void *p = &a;        double b = 3.14;        p = &b;        c = a + b;        cout << c << '\n' << p;        return 0;    }

Choices:
- 8, memory address
- 8.14
- memory address
- 12


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    struct Time     {        int hours;        int minutes;        int seconds;    };    int toSeconds(Time now);    int main()    {        Time t;        t.hours = 5;        t.minutes = 30;        t.seconds = 45;        cout << "Total seconds: " << toSeconds(t) << endl;        return 0;    }    int toSeconds(Time now)    {        return 3600 * now.hours + 60 * now.minutes + now.seconds;    }

Choices:
- 19845
- 20000
- 15000
- 19844


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        struct ShoeType         {           string style;           double price;        };         ShoeType shoe1, shoe2;         shoe1.style = "Adidas";         shoe1.price = 9.99;         cout << shoe1.style << " $ "<< shoe1.price;         shoe2 = shoe1;         shoe2.price = shoe2.price / 9;         cout << shoe2.style << " $ "<< shoe2.price;         return 0;    }

Choices:
- Adidas $ 9.99Adidas $ 1.11
- Adidas $ 9.99Adidas $ 9.11
- Adidas $ 9.99Adidas $ 11.11
- Adidas $ 11.11Adidas $ 11.11


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    struct sec     {        int a;        char b;    };    int main()    {        struct sec s ={25,50};        struct sec *ps =(struct sec *)&s;        cout << ps->a << ps->b;        return 0;    }

Choices:
- 252
- 253
- 254
- 262


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[12] = "Hello World";
	for(int i=0;i<12;i++)
        {
		cout<<(bool)isalpha(arr[i]);
	}
}

Choices:
- 111110111110
- 111111111110
- 111000111110
- 111110000000


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[12] = "H3ll0\tW0r1d";
	for(int i=0;i<12;i++)
        {
		cout<<(bool)isprint(arr[i]);
	}
}

Choices:
- 111000111110
- 111111111110
- 111110111110
- 111110000000


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[12] = "H3ll0\tW0r1d";
	for(int i=0;i<12;i++)
        {
		cout<<(bool)iscntrl(arr[i]);
	}
}

Choices:
- 111111111110
- 000001000001
- 111000111110
- 111110000000


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[20] = "\'H3ll0\'";
	for(int i=0;i<8;i++)
        {
		cout<<(bool)ispunct(arr[i]);
	}
}

Choices:
- 10000010
- 111111111110
- 111000111110
- 111110000000


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[27] = "abcdefghijklmnopqrstuvwxyz";
	for(int i=0;i<27;i++)
        {
		cout<<(bool)isxdigit(arr[i]);
	}
}


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a;        a = 5 + 3 * 5;        cout << a;        return 0;    }

Choices:
- 35
- 20
- 25
- 30


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 5, b = 6, c, d;        c = a, b;        d = (a, b);        cout << c << ' ' << d;        return 0;    }

Choices:
- 5  6
- 6  5
- 6  7
- 6  8


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int i, j;        j = 10;        i = (j++, j + 100, 999 + j);        cout << i;        return 0;    }

Choices:
- 1000
- 11
- 1010
- 1001


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main ()    {        int x, y;        x = 5;        y = ++x * ++x;        cout << x << y;        x = 5;        y = x++ * ++x;        cout << x << y;        return 0;    }

Choices:
- 749735
- 736749
- 367497
- 367597


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 5, b = 6, c;        c = (a > b) ? a : b;        cout << c;        return 0;    }

Choices:
- 6
- 5
- 4
- 7


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    main()    {        double a = 21.09399;        float b = 10.20;        int c ,d;        c = (int) a;        d = (int) b;        cout << c <<' '<< d;        return 0;    }

Choices:
- 20 10
- 10 21
- 21 10
- 10 20


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main ()    {        int n;        for (n = 5; n > 0; n--)        {            cout << n;            if (n == 3)                break;        }        return 0;    }

Choices:
- 543
- 54
- 5432
- 53


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 10;        if (a < 15)        {            time:            cout << a;            goto time;        }        break;        return 0;    }

Choices:
- 1010
- 10
- infinitely print 10
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int n = 15;        for ( ; ;)        cout << n;        return 0;    }

Choices:
- error
- 15
- infinite times of printing n
- none of the mentioned


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int i;        for (i = 0; i < 10; i++);        {            cout << i;        }        return 0;    }

Choices:
- 0123456789
- 10
- 012345678910
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        /* this is comment*        cout << "hello world";        return 0;    }

Choices:
- hello world
- hello
- compile time error
- hellohello


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    long factorial (long a)    {        if (a > 1)            return (a * factorial (a + 1));        else            return (1);    }    int main ()    {        long num = 3;        cout << num << "! = " << factorial ( num );        return 0;    }

Choices:
- 6
- 24
- segmentation fault
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void square (int *x)    {	*x = (*x + 1) * (*x);    }    int main ( )    {	int num = 10;        square(&num);	cout << num;	return 0;    }

Choices:
- 100
- compile time error
- 144
- 110


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int add(int a, int b);    int main()    {        int i = 5, j = 6;        cout << add(i, j) << endl;        return 0;    }    int add(int a, int b )    {        int sum = a + b;        a = 7;        return a + b;    }

Choices:
- 11
- 12
- 13
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void Sum(int a, int b, int & c)    {        a = b + c;        b = a + c;        c = a + b;    }    int main()    {        int x = 2, y =3;        Sum(x, y, y);        cout << x << " " << y;        return 0;    }

Choices:
- 2 3
- 6 9
- 2 15
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void mani()    void mani()    {        cout<<"hai";    }    int main()    {        mani();        return 0;    }

Choices:
- hai
- haihai
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void fun(int x, int y)    {        x = 20;        y = 10;    }    int main()    {        int x = 10;        fun(x, x);        cout << x;        return 0;    }

Choices:
- 10
- 20
- compile time error
- 30


Question:
What will be the output of the following C++ code?
#include<iostream>
using namespace std;

int fun(int x = 0, int y = 0, int z)
{  return (x + y + z); }

int main()
{
   cout << fun(10);
   return 0;
}

Choices:
- 10
- 0
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;

int fun(int=0, int = 0);

int main()
{
  cout << fun(5);
  return 0;
}
int fun(int x, int y) { return (x+y); }

Choices:
- -5
- 0
- 10
- 5


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void square (int *x, int *y)
{
	*x = (*x) * --(*y);
}
int main ( )
{
	int number = 30;
	square(&number, &number);
	cout << number;
	return 0;
}

Choices:
- 870
- 30
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void copy (int& a, int& b, int& c)    {        a *= 2;        b *= 2;        c *= 2;    }    int main ()    {        int x = 1, y = 3, z = 7;        copy (x, y, z);        cout << "x =" << x << ", y =" << y << ", z =" << z;        return 0;    }

Choices:
- 2 5 10
- 2 4 5
- 2 6 14
- 2 4 9


Question:
What will be the new value of x in the following C++ code?
    #include <iostream>    using namespace std;    void fun(int &x)    {        x = 20;    }    int main()    {         int x = 10;         fun(x);         cout << "New value of x is " << x;         return 0;    }

Choices:
- 10
- 20
- 15
- 36


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    long factorial (long a)    {        if (a > 1)            return (a * factorial (a + 1));        else            return (1);    }    int main ()    {        long num = 3;        cout << num << "! = " << factorial ( num );        return 0;    }

Choices:
- 6
- 24
- segmentation fault
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void square (int *x)    {	*x = (*x + 1) * (*x);    }    int main ( )    {	int num = 10;        square(&num);        cout << num;         return 0;    }

Choices:
- 100
- compile time error
- 144
- 110


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int add(int a, int b);    int main()    {        int i = 5, j = 6;        cout << add(i, j) << endl;        return 0;    }    int add(int a, int b )    {        int sum = a + b;        a = 7;        return a + b;    }

Choices:
- 11
- 12
- 13
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void Sum(int a, int b, int & c)    {        a = b + c;        b = a + c;        c = a + b;    }    int main()    {        int x = 2, y =3;        Sum(x, y, y);        cout << x << " " << y;        return 0;     }

Choices:
- 2 3
- 6 9
- 2 15
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int max(int a, int b )    {        return ( a > b ? a : b );    }    int main()    {        int i = 5;        int j = 7;        cout << max(i, j );        return 0;    }

Choices:
- 5
- 7
- either 5 or 7
- 13


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    double & WeeklyHours()    {        double h = 46.50;        double &hours = h;        return hours;    }    int main()    {        double hours = WeeklyHours();        cout << "Weekly Hours: " << hours;        return 0;    }

Choices:
- 46.5
- 6.50
- compile time error
- 26.5


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int mult (int x, int y)    {        int result;        result = 0;        while (y != 0)         {            result = result + x;            y = y - 1;        }        return(result);    }    int main ()    {        int x = 5, y = 5;        cout  << mult(x, y) ;        return(0);    }

Choices:
- 20
- 25
- 30
- 35


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int gcd (int a, int b)    {        int temp;        while (b != 0)         {            temp = a % b;            a = b;            b = temp;        }        return(a);    }    int main ()    {        int x = 15, y = 25;        cout << gcd(x, y);        return(0);    }

Choices:
- 15
- 25
- 375
- 5


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void print(int i)    {        cout << i;    }    void print(double  f)    {        cout << f;    }    int main(void)    {        print(5);        print(500.263);        return 0;    }

Choices:
- 5500.263
- 500.2635
- 500.263
- 500.266


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int Add(int X, int Y, int Z)    {        return X + Y;    }    double Add(double X, double Y, double Z)    {        return X + Y;    }    int main()    {        cout << Add(5, 6);        cout << Add(5.5, 6.6);        return 0;    }

Choices:
- 11 12.1
- 12.1 11
- 11 12
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int operate (int a, int b)    {        return (a * b);    }    float operate (float a, float b)    {        return (a / b);    }    int main()    {        int x = 5, y = 2;        float n = 5.0, m = 2.0;        cout << operate(x, y) <<"\t";        cout << operate (n, m);        return 0;    }

Choices:
- 10.0	5.0
- 5.0	2.5
- 10.0 5
- 10   2.5


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void func(int a, bool flag = true)    {        if (flag == true )         {            cout << "Flag is true. a = " << a;        }        else         {            cout << "Flag is false. a = " << a;        }    }    int main()    {        func(200, false);        return 0;    }

Choices:
- Flag is true. a = 200
- Flag is false. a = 100
- Flag is false. a = 200
- Flag is true. a = 100


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <string>    using namespace std;    string askNumber(string prompt = "Please enter a number: ");    int main()    {        string number = askNumber();        cout << "Here is your number: " << number;        return 0;    }    string askNumber(string prompt)    {        string number;        cout << prompt;        cin >> number;        return number;    }

Choices:
- 5
- 6
- the number you entered
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int func(int m = 10, int n)    {        int c;        c = m + n;        return c;    }    int main()    {        cout << func(5);        return 0;    }

Choices:
- 15
- 10
- compile time error
- 30


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <stdarg.h>    using namespace std;    float avg( int Count, ... )    {        va_list Numbers;        va_start(Numbers, Count);        int Sum = 0;        for (int i = 0; i < Count; ++i )            Sum += va_arg(Numbers, int);        va_end(Numbers);        return (Sum/Count);    }    int main()    {        float Average = avg(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);        cout << "Average of first 10 whole numbers : " << Average;        return 0;    }

Choices:
- 4
- 5
- 6
- 7


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <stdarg.h>    using namespace std;    int add (int num, ...)    {        int sum = 0;        va_list args;        va_start (args,num);        for (int i = 0; i < num; i++)         {            int num = va_arg (args,int);            sum += num;        }        va_end (args);        return sum;    }    int main (void)    {        int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7);        cout << "The result is " << total;        return 0;    }

Choices:
- 32
- 23
- 48
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <stdarg.h>    using namespace std;    void dumplist(int, ...);    int main()    {        dumplist(2, 4, 8);        dumplist(3, 6, 9, 7);        return 0;    }    void dumplist(int n, ...)    {        va_list p;        int i;        va_start(p, n);        while (n-->0)         {            i = va_arg(p, int);            cout << i;        }        va_end(p);    }

Choices:
- 2436
- 48697
- 1111111
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <stdarg.h>    using namespace std;    int flue(char c,...);    int main()    {        int x, y;        x = flue('A', 1, 2, 3);        y = flue('1', 1.0,1, '1', 1.0f, 1l);        cout << x << y;        return 0;    }    int flue(char c,...)    {        return c;    }

Choices:
- 6549
- 4965
- 6646
- compile time error


Question:
Which of the header file should be added in the following C++ code to properly run the program?
    #include <iostream>    using namespace std;    int print_all (int num, ...)    {        int sum = 0;        va_list args;        va_start (args,num);        for (int i = 0; i < num; i++)         {            int num = va_arg (args,int);            cout<<num<<" ";        }        va_end (args);        return sum;    }    int main (void)    {        print_all(8, 1, 2, -1, 4, 12, -2, 9, 7);        return 0;    }

Choices:
- stdlib.h
- stdarg.h
- string.h
- stdpar.h


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <stdarg.h>    using namespace std;    void fun(std::string msg, ...);    int main()    {        fun("IndiaBIX", 1, 4, 7, 11, 0);        return 0;    }    void fun(std::string msg, ...)    {        va_list ptr;        int num;        va_start(ptr, msg);        num = va_arg(ptr, int);        num = va_arg(ptr, int);        cout << num;    }

Choices:
- 6
- 5
- 8
- 4


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int add(int first, int second)    {        return first + second + 15;    }    int operation(int first, int second, int (*functocall)(int, int))    {        return (*functocall)(first, second);    }    int main()    {        int  a;        int  (*plus)(int, int) = add;        a = operation(15, 10, plus);        cout << a;        return 0;    }

Choices:
- 25
- 35
- 40
- 45


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void func(int x)    {        cout << x ;    }    int main()    {        void (*n)(int);        n = &func;        (*n)( 2 );        n( 2 );        return 0;    }

Choices:
- 2
- 20
- 21
- 22


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int func (int a, int b)    {        cout << a;        cout << b;        return 0;    }    int main(void)    {        int(*ptr)(char, int);        ptr = func;        func(2, 3);        ptr(2, 3);        return 0;    }

Choices:
- 2323
- 232
- 23
- compile time error


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

Choices:
- ptr is pointer to function
- ptr is array of pointer to function
- ptr is pointer to such function which return type is array
- ptr is pointer to array of function


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    #define MIN(a,b) (((a)<(b)) ? a : b)    int main ()    {        float i, j;        i = 100.1;        j = 100.01;        cout <<"The minimum is " << MIN(i, j) << endl;        return 0;    }

Choices:
- 100.01
- 100.1
- compile time error
- 100


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main ()    {        cout << "Value of __LINE__ : " << __LINE__ << endl;        cout << "Value of __FILE__ : " << __FILE__ << endl;        cout << "Value of __DATE__ : " << __DATE__ << endl;        cout << "Value of __TIME__ : " << __TIME__ << endl;        return 0;    }

Choices:
- 5
- details about your file
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    #define SquareOf(x) x * x    int main()    {        int x;        cout << SquareOf(x + 4);        return 0;    }

Choices:
- 16
- 64
- compile time error
- 75386824


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    #define PR(id) cout << "The value of " #id " is "<<id    int main()    {        int i = 10;        PR(i);        return 0;    }

Choices:
- 10
- 15
- 20
- 12


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    #define MAX 10    int main()    {        int num;        num = ++MAX;        cout << num;        return 0;    }

Choices:
- 11
- 10
- compile time error
- 13


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    namespace first    {        int var = 5;    }    namespace second    {        double var = 3.1416;    }    int main ()    {        int a;        a = first::var + second::var;        cout << a;        return 0;   }

Choices:
- 8.31416
- 8
- 9
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    namespace first    {        int x = 5;        int y = 10;    }    namespace second    {        double x = 3.1416;        double y = 2.7183;    }    int main ()    {        using first::x;        using second::y;        bool a, b;        a = x > y;        b = first::y < second::x;        cout << a << b;        return 0;    }

Choices:
- 11
- 01
- 00
- 10


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    namespace Box1    {        int a = 4;    }    namespace Box2    {        int a = 13;    }    int main ()    {        int a = 16;        Box1::a;        Box2::a;        cout << a;        return 0;    }

Choices:
- 4
- 13
- 16
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    namespace space    {        int x = 10;    }    namespace space    {        int y = 15;    }    int main(int argc, char * argv[])    {        space::x = space::y =5;        cout << space::x << space::y;    }

Choices:
- 1015
- 1510
- 55
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    namespace extra    {        int i;    }    void i()    {        using namespace extra;        int i;        i = 9;        cout << i;    }    int main()    {        enum  letter { i, j};        class i { letter j; };        ::i();        return 0;    }

Choices:
- 9
- 10
- compile time error
- 11


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace A{

	int var = 10;
}
namespace B{
	int cout = 5;
}
int main()
{
	using namespace B;
	cout<<A::var;
}

Choices:
- 10
- 5
- Error
- 105


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace A{

	int var = 10;
}
namespace B{
	int var = 5;
}
int main()
{
	using namespace B;
	cout<<var;
}

Choices:
- 5
- 10
- Error
- Wrong use of namespace


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace A{

	int var = 10;
}
namespace B{
	int var = 5;
}
int main()
{
	int var = 20;
	using namespace B;
	cout<<var;
}

Choices:
- 5
- 10
- 20
- Error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace
{
	int var = 10;
}
int main()
{
	cout<<var;
}

Choices:
- 10
- Error
- Some garbage value
- Nothing but program runs perfectly


Question:
How to print the value of the i variable inside namespace B?
namespace A{
	int var = 10;
	namespace B{
		int i = 15;
	}
}

Choices:
- cout<<A::i;
- cout<<B::i;
- cout<<A::B::i;
- cout<<i;


Question:
What will be the output of following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace My_old_school_and_college_friends_number
{
	long int f1 = 9999999999;
	long int f2 = 1111111111;
}
namespace contacts = My_old_school_and_college_friends_number;
int main(){

	cout<<contacts::f1;
}

Choices:
- 9999999999
- 1111111111
- error
- segmentation fault


Question:
What changes you can do in the header files to avoid the redefinition that compiler will give when both the header files are included in the same program keeping the declaration of both the functions same?
Content of h1.h
------------------------------------------------
h1.h
#include <iostream>
using namespace std;
int func(int a){
	cout<<"Multiplied by 2";
	return 2*a;
}
------------------------------------------------

Content of h2.h
------------------------------------------------
h2.h
#include <iostream>
using namespace std;
int func(int a){
	cout<<"divided by 2";
	return a/2;
}
------------------------------------------------

Choices:
- Cannot be handled because C++ does not allow this
- Declare both the function inside different namespaces
- Include one header files where they are needed so that no clashes occur
- Make the header files name same


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int age = 0;        try         {            if (age < 0)             {                throw "Positive Number Required";            }            cout << age;        }        catch(const char *Message)        {            cout << "Error: " << Message;        }        return 0;    }

Choices:
- 0
- error:Positive Number Required
- compile time error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void PrintSequence(int StopNum)    {        int Num;        Num = 1;        while (true)         {            if (Num >= StopNum)                throw Num;            cout << Num;            Num++;        }    }    int main(void)    {        try         {            PrintSequence(20);        }        catch(int ExNum)        {            cout << "Caught an exception with value: " << ExNum;        }        return 0;    }

Choices:
- compile time error
- prints first 19 numbers
- prints first 19 numbers and throws exception at 20
- prints first 17 numbers


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    double division(int a, int b)    {        if (b == 0)         {            throw "Division by zero condition!";        }        return (a / b);    }    int main ()    {        int x = 50;        int y = 2;        double z = 0;        try         {            z = division(x, y);            cout << z;        }        catch(const char *msg)         {            cerr << msg;        }        return 0;    }

Choices:
- 25
- 20
- Division by zero condition!
- 35


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        char* buff;        try         {            buff = new char[1024];            if (buff == 0)               throw "Memory allocation failure!";            else               cout << sizeof(buff) << "Byte successfully allocated!"<<endl;        }        catch(char *strg)        {            cout<<"Exception raised: "<<strg<<endl;        }        return 0;    }

Choices:
- 4 Bytes allocated successfully
- 8 Bytes allocated successfully
- Memory allocation failure
- Depends on the size of the data type


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    void Funct();    int main()    {        try         {            Funct();        }        catch(double)         {            cerr << "caught a double type..." << endl;        }        return 0;    }    void Funct()    {        throw 3;    }

Choices:
- caught a double type
- compile time error
- abnormal program termination
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <exception>    using namespace std;    int main()    {        try         {            int * array1 = new int[100000000];            int * array2 = new int[100000000];            int * array3 = new int[100000000];            int * array4 = new int[100000000];            cout << "Allocated successfully";        }        catch(bad_alloc&)         {            cout << "Error allocating the requested memory." << endl;        }        return 0;    }

Choices:
- Allocated successfully
- Error allocating the requested memory
- Depends on the memory of the computer
- Error


Question:
ii.
    #include <iostream>    #include "exe.h"    using namespace std;    int main(int argc, char * argv[] )    {        cout << number++;        return 0;    }

Choices:
- 842
- 843
- compile time error
- 845


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        char name[30];        cout << "Enter name: ";        gets(name);        cout << "Name: ";        puts(name);        return 0;    }

Choices:
- jobsjobs
- jobs
- compile time error
- program will not run


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <stdarg.h>    using namespace std;    float avg( int Count, ... )    {        va_list Numbers;        va_start(Numbers, Count);        int Sum = 0;        for (int i = 0; i < Count; ++i)            Sum += va_arg(Numbers, int);        va_end(Numbers);        return (Sum/Count);    }    int main()    {        float Average = avg(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);        cout << Average;        return 0;    }

Choices:
- 4
- 5
- 6
- compile time error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class rect    {        int x, y;        public:        void val (int, int);        int area ()        {            return (x * y);        }    };    void rect::val (int a, int b)    {        x = a;        y = b;    }    int main ()    {        rect rect;        rect.val (3, 4);        cout << "rect area: " << rect.area();        return 0;    }

Choices:
- rect area: 24
- rect area: 12
- compile error because rect is as used as class name and variable name in line #20
- rect area: 56


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class CDummy    {        public:        int isitme (CDummy& param);    };    int CDummy::isitme (CDummy& param)    {        if (&param == this)            return true;        else            return false;    }    int main ()    {        CDummy a;        CDummy *b = &a;        if (b->isitme(a))         {            cout << "execute";        }        else        {            cout<<"not execute";        }        return 0;    }

Choices:
- execute
- not execute
- error
- both execute & not execute


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a;

   public:
	int assign(int i) const {
		a = i;
	}
	int return_value() const {
		return a;
	}
};
int main(int argc, char const *argv[])
{
	A obj;
	obj.assign(5);
	cout<<obj.return_value();
}

Choices:
- 5
- 10
- Error
- Segmentation fault


Question:
What is the correct syntax of accessing a static member of a Class?
---------------------------
Example class:
class A
{
	public:
		static int value;
}
---------------------------

Choices:
- A.value
- A::value
- A->value
- A^value


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;

class A
{
	mutable int a;

        public:
	int assign(int i) const {
		a = i;
	}
	int return_value() const {
		return a;
	}

};

int main(int argc, char const *argv[])
{
	A obj;
	obj.assign(5);
	cout<<obj.return_value();
}

Choices:
- 5
- Error
- Segmentation fault
- Undefined value


Question:
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class S
{
	int m;
   public:
	#define MAC(S::m)
};

int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}

Choices:
- Hello World
- Error
- Segmentation Fault
- Blank Space


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;

class A
{
	static int a;

   public:
	void change(int i){
		a = i;
	}
	void value_of_a(){
		cout<<a;
	}
};

int main(int argc, char const *argv[])
{
	A a1 = A();
	a1.change(5);
	a1.value_of_a();
	return 0;
}

Choices:
- 5
- Garbage value
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	static int a;
    public:
	void change(int i){
		a = i;
	}
	void value_of_a(){
		cout<<a;
	}
};

int A::a = 5;

int main(int argc, char const *argv[])
{
	A a1 = A();
	A a2 = A();
	A a3 = A();
	a1.change(10);
	a1.value_of_a();
	a2.value_of_a();
	a3.value_of_a();
	return 0;
}

Choices:
- 1055
- 555
- 101010
- 51010


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a = 5;
    public:
	void change(int i){
		a = i;
	}
	static void value_of_a(){
		cout<<a;
	}
};

int main(int argc, char const *argv[])
{
	A a1 = A();
	a1.change(10);
	a1.value_of_a();
	return 0;
}

Choices:
- 10
- Error
- Segmentation Fault
- 5


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        typedef int num;        num a = 10, b = 15;        num c = a + b + a - b;        cout << c;        return 0;    }

Choices:
- 20
- 15
- 30
- 25


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int i;        enum month         {            JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,DEC        };        for (i = JAN; i <= DEC; i++)            cout << i;        return 0;    }

Choices:
- 012345678910
- 0123456789
- 01234567891011
- 01234567891011122


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        typedef int num;        typedef char let;        let w = "steve";        num a = 10, b = 15;        num c = a + w;        cout << c;        return 0;    }

Choices:
- 10steve
- steve10
- compile time error
- compile but not run


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class Box    {        public :        double length;        double breadth;        double height;    };    int main( )    {        Box Box1;        double volume;        Box1.height = 5;        Box1.length = 6;        Box1.breadth = 7.1;        volume = Box1.height * Box1.length * Box1.breadth;        cout << "Volume of Box1 : " << volume <<endl;        return 0;    }

Choices:
- 210
- 213
- 215
- 217


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class Rect    {        int x, y;        public:        void set_values (int,int);        int area ()        {            return (x * y);        }    };    void Rect::set_values (int a, int b)     {        x = a;        y = b;    }    int main ()    {        Rect recta, rectb;        recta.set_values (5, 6);        rectb.set_values (7, 6);        cout << "recta area: " << recta.area();        cout << "rectb area: " << rectb.area();        return 0;    }

Choices:
- recta area: 30 rectb area: 42
- recta area: 20 rectb area: 34
- recta area: 30 rectb area: 21
- recta area: 30 rectb area: 33


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class number    {        int i;        public:        int geti();        void puti(int j);    };    int number::geti()    {        return i;    }    void number::puti(int j)    {        i = j;    }    int main()    {        number s;        s.puti(10);        cout << s.geti( );        return 0;    }

Choices:
- 10
- 11
- 20
- 22


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample     {        public:        int x, y;        sample() {};        sample(int, int);        sample operator + (sample);    };    sample::sample (int a, int b)     {        x = a;        y = b;    }    sample sample::operator+ (sample param)     {        sample temp;        temp.x = x + param.x;        temp.y = y + param.y;        return (temp);    }    int main ()     {        sample a (4,1);        sample b (3,2);        sample c;        c = a + b;        cout << c.x << "," << c.y;        return 0;    }

Choices:
- 5, 5
- 7, 3
- 3, 7
- 3, 5


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class myclass    {        public:        int i;        myclass *operator->()        {return this;}    };    int main()    {        myclass ob;        ob->i = 10;         cout << ob.i << " " << ob->i;        return 0;    }

Choices:
- 10 10
- 11 11
- error
- runtime error


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    ostream & operator<<(ostream & i, int n)    {        return i;    }    int main()    {        cout << 5 << endl;        cin.get();        return 0;    }

Choices:
- 5
- 6
- error
- runtime error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	static int a;
    public:
	void show()
        {
		a++;
		cout<<"a: "<<a<<endl;
	}
};

int A::a = 5;

int main(int argc, char const *argv[])
{
	A a;
	return 0;
}

Choices:
- Error as a private member a is referenced outside the class
- Segmentation fault
- No output
- Program compiles successfully but gives run-time error


Question:
What happens when objects s1 and s2 are added?
string s1 = "Hello";
string s2 = "World";
string s3 = (s1+s2).substr(5);

Choices:
- Error because s1+s2 will result into string and no string has substr() function
- Segmentation fault as two string cannot be added in C++
- The statements runs perfectly
- Run-time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	static int a;
    public:
	A()
        {
		cout<<"Object of A is created\n";
	}
	void show()
        {
		a++;
		cout<<"a: "<<a<<endl;
	}
};

class B
{
    public:
};

int main(int argc, char const *argv[])
{
	A a1, a2;
	A a3 = a1 + a2;
	return 0;
}

Choices:
- Runs perfectly
- Run-time Error
- Segmentation fault
- Compile-time Error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	static int a;

   public:
	void show()
        {
		a++;
		cout<<"a: "<<a<<endl;
	}
	void operator.()
        {
		cout<<"Objects are added\n";
	}
};

class B
{
     public:
};

int main(int argc, char const *argv[])
{
	A a1, a2;
	return 0;
}

Choices:
- Run-time Error
- Runs perfectly
- Segmentation fault
- Compile-time error


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class complex
{

	int i;
	int j;
        public:
	complex(int a, int b)
        {
		i = a;
		j = b;
	}

	complex operator+(complex c)
        {
		complex temp;
		temp.i = this->i + c.i;
		temp.j = this->j + c.j;
		return temp;
	}

	void show(){
		cout<<"Complex Number: "<<i<<" + i"<<j<<endl;
	}
};

int main(int argc, char const *argv[])
{
	complex c1(1,2);
	complex c2(3,4);
	complex c3 = c1 + c2;
	c3.show();
	return 0;
}

Choices:
- 4 + i6
- 2 + i2
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class complex
{
	int i;
	int j;
        public:
	complex(){}
	complex(int a, int b)
        {
	        i = a;
		j = b;
	}

	complex operator+(complex c)
        {
		complex temp;
		temp.i = this->i + c.i;
		temp.j = this->j + c.j;
		return temp;
	}

	void show(){
		cout<<"Complex Number: "<<i<<" + i"<<j<<endl;
	}
};

int main(int argc, char const *argv[])
{
	complex c1(1,2);
	complex c2(3,4);
	complex c3 = c1 + c2;
	c3.show();
	return 0;
}

Choices:
- Complex Number: 4 + i6
- Complex Number: 2 + i2
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class complex
{
	int i;
	int j;
      public:
	complex(){}
	complex(int a, int b)
        {
		i = a;
		j = b;
	}
	complex operator+(complex c)
        {
		complex temp;
		temp.i = this->i + c.i;
		temp.j = this->j + c.j;
		return temp;
	}

	void operator+(complex c)
        {
		complex temp;
		temp.i = this->i + c.i;
		temp.j = this->j + c.j;
		temp.show_poss();
	}

	void show(){
		cout<<"Complex Number: "<<i<<" + i"<<j<<endl;
	}

	void show_poss(){
		cout<<"Your result after addition will be: "<<i<<" + i"<<j<<endl;
	}
};

int main(int argc, char const *argv[])
{
	complex c1(1,2);
	complex c2(3,4);
	c1 + c2;
	return 0;
}

Choices:
- Complex Number: 4 + i6
- Complex Number: 2 + i2
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box
{
	int capacity;
	Box(){}
	Box(double capacity){
		this->capacity = capacity;
	}

};

int main(int argc, char const *argv[])
{
	Box b1(10);
	Box b2 = Box(14);
	return 0;
}

Choices:
- Error
- Segmentation fault
- 4
- No output


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box{
	int capacity;
	bool operator<(Box b){
		return this->capacity < b.capacity ? true : false;
	}
public:
	Box(){}
	Box(double capacity){
		this->capacity = capacity;
	}

};

int main(int argc, char const *argv[])
{
	Box b1(10);
	Box b2 = Box(14);
	if(b1 < b2){
		cout<<"Box 2 has large capacity.";
	}
	else{
		cout<<"Box 1 has large capacity.";
	}
	return 0;
}

Choices:
- Error
- Segmentation fault
- Box 2 has large capacity
- No output


Question:
Which operator should be overloaded in the following code to make the program error free?
#include <iostream>
#include <string>
using namespace std;
class Box{
	int capacity;
public:
	Box(){}
	Box(double capacity){
		this->capacity = capacity;
	}
};
int main(int argc, char const *argv[])
{
	Box b1(10);
	Box b2 = Box(14);
	if(b1 == b2){
		cout<<"Equal";
	}
	else{
		cout<<"Not Equal";
	}
	return 0;
}


Question:
Give the function prototype of the operator function which we need to define in this program so that the program has no errors.
#include <iostream>
#include <string>
using namespace std;
class Box{
	int capacity;
public:
	Box(){}
	Box(double capacity){
		this->capacity = capacity;
	}
};

int main(int argc, char const *argv[])
{
	Box b1(10);
	Box b2 = Box(14);
	if(b1 == b2){
		cout<<"Equal";
	}
	else{
		cout<<"Not Equal";
	}
	return 0;
}

Choices:
- bool operator==();
- bool operator==(Box b){}
- bool operator==(Box b);
- Box operator==();


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box{
	int capacity;
public:
	Box(){}
	Box(double capacity){
		this->capacity = capacity;
	}
	bool operator<(Box b){
		return b.capacity < this->capacity? true : false;
	}
};

int main(int argc, char const *argv[])
{
	Box b1(10);
	Box b2 = Box(14);
	if(b1 < b2){
		cout<<"B1's capacity is small";
	}
	else{
		cout<<"B2's capacity is small";
	}
	return 0;
}

Choices:
- B1's capacity is small
- B2's capacity is small
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <complex>    using namespace std;    int main()     {       complex<double> c1(4.0, 16.0), c2;       c2 = pow(c1, 2.0);       cout << c2;       return 0;              }

Choices:
- (-240, 128)
- (240, 128)
- (240, 120)
- (240, -122)


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <complex>    using namespace std;    int main()    {        complex<double> c_double(2, 3);        complex<int> c_int(4, 5);        c_double *= 2;        c_double = c_int;        cout << c_double;        return 0;    }

Choices:
- (2, 3)
- (4, 5)
- (8, 15)
- (8, 10)


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <complex>    using namespace std;    int main()    {        complex<int> i(2, 3);        i = i * 6 / 3;        cout << i;        return 0;    }

Choices:
- (4, 6)
- (2, 3)
- (6, 12)
- (6, 15)


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <complex>    using namespace std;    int main()    {       complex<double> c1(4.0,3.0);       cout << "c1: " << c1;       complex<float> c2(polar(5.0,0.75));       cout << c1 + complex<double>(c2.real(),c2.imag());       return 0;    }

Choices:
- c1: (4,3)(7.65844,6.40819)
- c1: (4,3)(7,6)
- both c1: (4,3)(7.65844,6.40819) & c1: (4,3)(7,6)
- c1: (5,3)(7,6)


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <complex>    using namespace std;    int main()    {        complex<double> c1(4.0, 3.0);        complex<float> c2(polar(5.0, 0.75));        cout  << (c1 += sqrt(c1)) << endl;        return 0;    }

Choices:
- (4.0, 3.0)
- (6.12132, 3.70711)
- (5.0, 0.75)
- (5.0, 3.75)


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <complex>    using namespace std;    int main ()    {        complex<double> mycomplex (20.0, 2.0);        cout << imag(mycomplex) << endl;        return 0;    }

Choices:
- 2
- 20
- 40
- 30


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample1     {        float i, j;    };    class sample2     {        int x, y;        public:        sample2 (int a, int b)         {             x = a;              y = b;        }        int result()         {              return x + y;         }    };    int main ()     {        sample1 d;        sample2 * padd;        padd = (sample2*) &d;        cout<< padd->result();        return 0;    }

Choices:
- 20
- runtime error
- random number
- runtime error or random number


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample    {        public:        sample(int i) : m_i(i) { }        public:        int operator()(int i = 0) const         {             return m_i + i;         }        operator int () const           {             return m_i;         }        private:        int m_i;        friend int g(const sample&);    };    int f(char c)    {        return c;    }    int main()    {        sample f(2);        cout << f(2);        return 0;    }

Choices:
- 3
- 4
- 5
- 6


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <cmath>    using namespace std;    class Complex    {        private:        double real;        double imag;        public:        Complex(double r = 0.0, double i = 0.0) : real(r), imag(i)        {}        double mag()        {              return getMag();        }        operator double ()        {            return getMag();        }        private:        double getMag()        {            return sqrt(real * real + imag * imag);        }    };    int main()    {        Complex com(3.0, 4.0);        cout << com.mag();        cout << com;        return 0    }

Choices:
- 5 5
- 4 5
- 6 6
- 7 5


Question:
What will be the output of the following C++ code?
    #include <iostream>    #include <string>    using namespace std;    class test    {        public:        operator string ()         {              return "Converted";        }    };    int main()    {        test t;        string s = t;        cout << s << endl;        return 0;    }

Choices:
- converted
- error
- run time error
- convertedconverted


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        double a = 21.09399;        float b = 10.20;        int c ;        c = (int) a;        cout << c ;        c = (int) b;        cout << c ;        return 0;    }

Choices:
- 2110
- 1210
- 21
- 121


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class Box    {        double width;        public:        friend void printWidth( Box box );        void setWidth( double wid );    };    void Box::setWidth( double wid )    {        width = wid;    }    void printWidth( Box box )    {        box.width = box.width * 2;        cout << "Width of box : " << box.width << endl;    }    int main( )    {        Box box;        box.setWidth(10.0);        printWidth( box );        return 0;   }

Choices:
- 40
- 5
- 10
- 20


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample     {        int width, height;        public:        void set_values (int, int);        int area () {return (width * height);}        friend sample duplicate (sample);    };    void sample::set_values (int a, int b)     {        width = a;        height = b;    }    sample duplicate (sample rectparam)    {        sample rectres;        rectres.width = rectparam.width * 2;        rectres.height = rectparam.height * 2;        return (rectres);    }      int main ()      {        sample rect, rectb;        rect.set_values (2, 3);        rectb = duplicate (rect);        cout << rectb.area();        return 0;    }

Choices:
- 20
- 16
- 24
- 18


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample;    class sample1     {        int width, height;        public:        int area ()        {            return (width * height);}            void convert (sample a);        };    class sample     {        private:        int side;        public:        void set_side (int a)        {             side = a;        }        friend class sample1;    };    void sample1::convert (sample a)     {        width = a.side;        height = a.side;    }    int main ()     {        sample sqr;        sample1 rect;        sqr.set_side(6);        rect.convert(sqr);        cout << rect.area();        return 0;    }

Choices:
- 24
- 35
- 16
- 36


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class base    {        int val1, val2;        public:        int get()	{            val1 = 100;            val2 = 300;	}        friend float mean(base ob);    };    float mean(base ob)    {        return float(ob.val1 + ob.val2) / 2;    }    int main()    {        base obj;        obj.get();        cout << mean(obj);        return 0;    }

Choices:
- 200
- 150
- 100
- 300


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample    {        private:        int a, b;        public:        void test()        {            a = 100;            b = 200;        }        friend int compute(sample e1);    };    int compute(sample e1)    {        return int(e1.a + e1.b) - 5;    }    int main()    {        sample e;        e.test();        cout  << compute(e);        return 0;    }

Choices:
- 100
- 200
- 300
- 295


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box
{
	int capacity;
    public:
	Box(int cap){
		capacity = cap;
	}

	friend void show();
};

void show()
{
	Box b(10);
	cout<<"Value of capacity is: "<<b.capacity<<endl;
}

int main(int argc, char const *argv[])
{
	show();
	return 0;
}

Choices:
- Value of capacity is: 10
- Value of capacity is: 100
- Error
- Segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box
{
	int capacity;
    public:
	Box(int cap){
		capacity = cap;
	}
	friend void show();
};

void Box::show()
{
	Box b(10);
	cout<<"Value of capacity is: "<<b.capacity<<endl;
}

int main(int argc, char const *argv[])
{
	show();
	return 0;
}

Choices:
- Value of capacity is: 10
- Value of capacity is: 100
- Error
- Segmentation fault


Question:
How many member functions are there in this C++ class excluding constructors and destructors?
class Box
{
	int capacity;
   public:
	void print();
	friend void show();
	bool compare();
	friend bool lost();
};

Choices:
- 1
- 2
- 3
- 4


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class B
{
	int b;
   public:
	B(int i){
		b = i;
	}
};

class C
{
	B b;
    public:
	C(int i){
		b = B(i);
	}
	friend void show();
};

void show()
{
	C c(10);
	cout<<"value of b is: "<<c.b.b<<endl;
}

int main(int argc, char const *argv[])
{
	show();
	return 0;
}

Choices:
- value of b is: 10
- value of b is: 12345435
- error
- segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class B
{
	int b;
     public:
	B(){}
	B(int i){
		b = i;
	}
	int show(){
		return b;
	}
};

class C
{
	B b;
     public:
	C(int i){
		b = B(i);
	}
	friend void show();
};

void show()
{
	C c(10);
	cout<<"value of b is: "<<c.b.show()<<endl;
}

int main(int argc, char const *argv[])
{
	show();
	return 0;
}

Choices:
- value of b is: 10
- value of b is: 12345435
- error
- segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class B
{
	int b;
   public:
	B(){}
	B(int i){
		b = i;
	}
	int show(){
		return b;
	}
};

class C
{
	B b;
    public:
	C(int i){
		b = B(i);
	}
	friend void show(){

		C c(10);
		cout<<"value of b is: "<<c.b.show()<<endl;
	}
};

int main(int argc, char const *argv[])
{
	show();
	return 0;
}

Choices:
- value of b is: 10
- value of b is: 12345435
- error
- segmentation fault


Question:
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class B
{
	int b;
    public:
	B(){}
	B(int i){
		b = i;
	}
	int show(){
		return b;
	}
};

class C
{
	B b;
    public:
	C(int i){
		b = B(i);
	}
	friend void show(){

		C c(10);
		cout<<"value of b is: "<<c.b.show()<<endl;
	}
};

int main(int argc, char const *argv[])
{
	C c(1);
	c.show();
	return 0;
}

Choices:
- value of b is: 10
- value of b is: 12345435
- error
- segmentation fault


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    class sample    {        public:        sample()         {              cout << "X::X()" << endl;         }        sample( sample const & )         {              cout << "X::X( X const & )" << endl;        }        sample& operator=( sample const & )        {             cout << "X::operator=(X const &)" << endl;        }    };    sample f()     {        sample tmp;        return tmp;    }    int main()     {        sample x = f();        return 0;    }

Choices:
- X::operator=(X const &)
- X::X( X const & )
- X::X()
- X::operator


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main ()    {        int a, b;                 a = 10;                   b = 4;                    a = b;                   b = 7;                   cout << "a:";        cout << a;        cout << " b:";        cout << b;        return 0;    }

Choices:
- a:4 b:7
- a:10 b:4
- a:4 b:10
- a:4 b:6


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main ()    {        int a, b, c;        a = 2;        b = 7;        c = (a > b) ? a : b;        cout << c;        return 0;    }

Choices:
- 2
- 7
- 9
- 14


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 0;        int b = 10;        if ( a && b )        {            cout << "true"<< endl ;        }        else        {            cout << "false"<< endl ;        }        return 0;    }

Choices:
- true
- false
- error
- 10


Question:
What will be the output of the following C++ code?
    #include <iostream>    using namespace std;    int main()    {        int a = 20;        int b = 10;        int c = 15;        int d = 5;        int e;        e = a + b * c / d;        cout << e << endl ;        return 0;    }

Choices:
- 50
- 60
- 70
- 90