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

C++ Programming

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

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

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

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

Answer: Option A

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

Cpp Programming, Functions

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

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

#include
#include
class IndiaBix
{
char txtMsg[50];
public:
IndiaBix(char *str = NULL)
{
if(str != NULL)
strcpy(txtMsg, str);
}
int BixFunction(char ch);
};
int IndiaBix::BixFunction(char ch)
{
static int i = 0;
if(txtMsg[i++] == ch)
return strlen((txtMsg + i)) - i;
else
return BixFunction(ch);
}
int main()
{
IndiaBix objBix("Welcome to IndiaBix.com!");
cout<< objBix.BixFunction('t'); return 0; }

[A].6
[B].8
[C].9
[D].15 

Answer: Option A

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

Cpp Programming, Functions

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

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

#include
class IndiaBix
{
int Num;
public:
IndiaBix(int x)
{
Num = x;
}
int BixFunction(void);
};
int IndiaBix::BixFunction(void)
{
static int Sum = 0;
int Dec;
Dec = Num % 10;
Num = Num / 10;
if((Num / 100)) BixFunction();
Sum = Sum * 10 + Dec;
return Sum;
}
int main()
{
IndiaBix objBix(12345);
cout<< objBix.BixFunction(); return 0; }

[A].123
[B].321
[C].345
[D].12345 

Answer: Option C

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

Cpp Programming, Functions

Cpp Programming Quiz 191 – 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
static double gDouble;
static float gFloat;
static double gChar;
static double gSum = 0;
class BaseOne
{
public:
void Display(double x = 0.0, float y = 0.0, char z = 'A')
{
gDouble = x;
gFloat = y;
gChar = int(z);
gSum = gDouble + gFloat + gChar;
cout << gSum; } }; class BaseTwo { public: void Display(int x = 1, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class Derived : public BaseOne, BaseTwo { void Show() { cout << gSum; } }; int main() { Derived objDev; objDev.BaseTwo::Display(10, 20, 'Z'); return 0; }

[A].The program will print the output 0.
[B].The program will print the output 120.
[C].The program will report run-time error.
[D].The program will report compile-time error. 

Answer: Option D

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

Cpp Programming, Functions

Cpp Programming Quiz 192 – 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, y, z;
public:
IndiaBix(int x = 100, int y = 30, int z = 0)
{
this->x = x;
this->y = y;
this->z = z;
Display();
}
void Display()
{
cout<< x << " " << y << " " << z; } }; int main() { int a = 0, b = 1, c = 2; int &x = ++a; int &y = --b; int z = c + b - -c; IndiaBix objBix(x, y, z); return 0; }

[A].The program will print the output 1 0 3.
[B].The program will print the output 1 0 4.
[C].The program will print the output 1 1 3.
[D].The program will print the output 1 1 4. 

Answer: Option B

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

Cpp Programming, Functions

Cpp Programming Quiz 193 – 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:
void BixFunction(int = 0, float = 0.00f, char = 'A');
void BixFunction(float, int = 10.00, char = 'Z');
void BixFunction(char, char, char);
};
int main()
{
IndiaBix objBix;
objBix.BixFunction(10 * 1.0, int(56.0));
return 0;
}
void IndiaBix::BixFunction(int xx, float yy, char zz)
{
x = xx + int(yy);
cout<< "x = " << x << endl; } void IndiaBix::BixFunction(float xx, int yy, char zz) { x = zz + zz; y = xx + yy; cout<< " x = " << x << endl; } void IndiaBix::BixFunction(char xx, char yy, char zz) { x = xx + yy + zz; y = float(xx * 2); cout<< " x = " << x << endl; }

[A].The program will print the output x = 65.
[B].The program will print the output x = 66.
[C].The program will print the output x = 130.
[D].The program will print the output x = 180. 

Answer: Option D

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

Cpp Programming, 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