Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

Functions

Cpp Programming Quiz 194 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
#include
class BixString
{
char x[50];
char y[50];
char z[50];
public:
BixString()
{ }
BixString(char* xx)
{
strcpy(x, xx);
strcpy(y, xx);
}
BixString(char *xx, char *yy = " C++", char *zz = " Programming!")
{
strcpy(z, xx);
strcat(z, yy);
strcat(z, zz);
}
void Display(void)
{
cout<< z << endl; } }; int main() { BixString objStr("Learn", " Java"); objStr.Display(); return 0; }

[A].Java Programming!
[B].C++ Programming!
[C].Learn C++ Programming!
[D].Learn Java Programming! 

Answer: Option D

Cpp Programming Quiz 194 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 195 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
struct BixArray
{
int arr[5];
public:
void BixFunction();
void Display();
};
void BixArray::BixFunction()
{
static int i = 0, j = 4;
i++;
j--;
if(j > 0)
BixFunction();
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i--;
j++;
}
void BixArray::Display()
{
for(int i = 0; i < 5; i++) cout<< arr[i] << " "; } int main() { BixArray objArr = {{5, 6, 3, 9, 0}}; objArr.BixFunction(); objArr.Display(); return 0; }

[A].5 6 3 9 0
[B].0 9 3 6 5
[C].0 5 6 3 9
[D].0 6 3 9 5 

Answer: Option D

Cpp Programming Quiz 195 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 196 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class Number
{
int Num;
public:
Number(int x = 0)
{
Num = x;
}
void Display(void)
{
cout<< Num; } void Modify(); }; void Number::Modify() { int Dec; Dec = Num % 13; Num = Num / 13; if(Num > 0 ) Modify() ;
if(Dec == 10) cout<< "A" ; else if(Dec == 11) cout<< "B" ; else if(Dec == 12) cout<< "C" ; else if(Dec == 13) cout<< "D" ; else cout<< Dec ; } int main() { Number objNum(130); objNum.Modify(); return 0; }

[A].130
[B].A0
[C].B0
[D].90 

Answer: Option B

Cpp Programming Quiz 196 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 197 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class Number
{
int Num;
public:
Number(int x = 0)
{
Num = x;
}
void Display(void)
{
cout<< Num; } void Modify(); }; void Number::Modify() { int Dec; Dec = Num % 13; Num = Num / 13; if(Num > 0 ) Modify() ;
if(Dec == 10) cout<< "A" ; else if(Dec == 11) cout<< "B" ; else if(Dec == 12) cout<< "C" ; else if(Dec == 13) cout<< "D" ; else cout<< Dec ; } int main() { Number objNum(130); objNum.Modify(); return 0; }

[A].10
[B].20
[C].30
[D].40 

Answer: Option C

Cpp Programming Quiz 197 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 198 – What is correct about the following program?

Question: What is correct about the following program?

#include
class Addition
{
int x;
public:
Addition()
{
x = 0;
}
Addition(int xx)
{
x = xx;
}
Addition operator + (int xx = 0)
{
Addition objTemp;
objTemp.x = x + xx;
return(objTemp);
}
void Display(void)
{
cout<< x << endl; } }; int main() { Addition objA(15), objB; objB = objA + 5; objB.Display(); return 0; }

[A].The program will print the output 20.
[B].The program will report run time error.
[C].The program will print the garbage value.
[D].Compilation fails due to 'operator +' cannot have default arguments. 

Answer: Option D

Cpp Programming Quiz 198 – What is correct about the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 199 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class Base
{
int x, y;
public:
Base()
{
x = y = 0;
}
Base(int xx)
{
x = xx;
}
Base(int p, int q = 10)
{
x = p + q;
y = q;
}
void Display(void)
{
cout<< x << " " << y << endl; } }objDefault(1, 1); class Derived: public Base { Base obj; public: Derived(int xx, int yy): Base(xx, xx + 1) { } Derived(Base objB = objDefault) { } }; int main() { Derived objD(5, 3); Derived *ptrD = new Derived(objD); ptrD->Display();
delete ptrD;
return 0;
}

[A].3 2
[B].8 3
[C].11 6
[D].11 10 

Answer: Option C

Cpp Programming Quiz 199 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 200 – Which of the following statement is correct about the program given below?

Question: Which of the following statement is correct about the program given below?

#include
class IndiaBix
{
int x;
float y;
public:
IndiaBix(int x)
{
x = x;
}
IndiaBix(int p = 0, int q = 10)
{
x = p += 2;
y = q * 1.0f;
}
void SetValue(int &y, float z)
{
x = y;
y = (int)z;
}
void Display(void)
{
cout<< x; } }; int main() { int val = 12; IndiaBix objBix(val); IndiaBix objTmp(); objBix.SetValue(val, 3.14f); objBix.Display(); return 0; }

[A].The program will print the output 2.
[B].The program will print the output 12.
[C].The program will report run time error.
[D].The program will not compile successfully. 

Answer: Option D

Cpp Programming Quiz 200 – Which of the following statement is correct about the program given below? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 201 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class IndiaBix
{
int x, y, z;
public:
void Apply(int xx = 12, int yy = 21, int zz = 9)
{
x = xx;
y = yy += 10;
z = x -= 2;
}
void Display(void)
{
cout<< x << " " << y << endl; } void SetValue(int xx, int yy) { Apply(xx, 0, yy); } }; int main() { IndiaBix *pBix= new IndiaBix; (*pBix).SetValue(12, 20); pBix->Display();
delete pBix;
return 0;
}

[A].10 10
[B].12 10
[C].12 21
[D].12 31 

Answer: Option A

Cpp Programming Quiz 201 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 202 – What is correct about the following program?

Question: What is correct about the following program?

#include
class Base
{
int x, y, z;
public:
Base()
{
x = y = z = 0;
}
Base(int xx, int yy = 'A', int zz = 'B')
{
x = xx;
y = x + yy;
z = x + y;
}
void Display(void)
{
cout<< x << " " << y << " " << z << endl; } }; class Derived : public Base { int x, y; public: Derived(int xx = 65, int yy = 66) : Base(xx, yy) { y = xx; x = yy; } void Display(void) { cout<< x << " " << y << " "; Display(); } }; int main() { Derived objD; objD.Display(); return 0; }

[A].The program will report compilation error.
[B].The program will run successfully giving the output 66 65.
[C].The program will run successfully giving the output 65 66.
[D].The program will run successfully giving the output 66 65 65 131 196. 

Answer: Option C

Cpp Programming Quiz 202 – What is correct about the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 203 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class Base
{
public:
char S, A, M;
Base(char x, char y)
{
S = y - y;
A = x + x;
M = x * x;
}
Base(char, char y = 'A', char z = 'B')
{
S = y;
A = y + 1 - 1;
M = z - 1;
}
void Display(void)
{
cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { char x, y, z; public: Derived(char xx = 65, char yy = 66, char zz = 65): Base(x) { x = xx; y = yy; z = zz; } void Display(int n) { if(n) Base::Display(); else cout<< x << " " << y << " " << z << endl; } }; int main() { Derived objDev; objDev.Display(0-1); return 0; }

[A].A A A
[B].A B A
[C].A B C
[D].Garbage Garbage Garbage 

Answer: Option A

Cpp Programming Quiz 203 – What will be the output of the following program? Read More »

Cpp Programming, Functions