Essay on The Republic Day | Republic Day Essay in English
[ Festival Ganesh Chaturthi Essay in English for Students and Children ] [ Essay on my favourite freedom fighter ] ⚔️ [ दुर्गा पूजा पर निबंध (Durga Puja Hindi Essay) ]
[Essay On 75th Independence Day Of India] [Azadi Ka Amrit Mahotsav Essay in English]

What will be the output of the following program?

Loading

Practice Constructors and Destructors –

What will be the output of the following program?

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

Which of the following statement is correct about the program given

Loading

Practice Constructors and Destructors –

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

#include 
class Crackexams {
int x;
float y;
public:
Crackexams(int x) {
x = x;
}
Crackexams(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;
Crackexams objCrackexams(val);
Crackexams objTmp();
objCrackexams.SetValue(val, 3.14f);
objCrackexams.Display();
return 0;
}

What will be the output of the following program?

Loading

Practice Constructors and Destructors –

What will be the output of the following program?

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

Predict the output of following program.


			  		

Loading

Practice Constructors and Destructors –

Predict the output of following program.

#include 
using namespace std;
class A
{
protected:
int x;
public:
A() {x = 0;}
friend void show();
};

class B: public A
{
public:
B() : y (0) {}
private:
int y;
};

void show()
{
A a;
B b;
cout << "The default value of A::x = " << a.x << " ";
cout << "The default value of B::y = " << b.y;
}