C++ Programming :: Functions - C++
-
What will be the output of the following program?
#include struct Freshergate { int arr[5]; public: void GATEFunction(void); void Display(void); }; void Freshergate::Display(void) { for(int i = 0; i 5; i++) cout" " ; } void Freshergate::GateFunction(void) { static int i = 0, j = 4; int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp ; i++; j--; if(j != i) GateFunction(); } int main() { Freshergate objGate = {{ 5, 6, 3, 9, 0 }}; objGate.GateFunction(); objGate.Display(); return 0; } -
Which of the following statement is correct about the program given below?
#include class Freshergate { int x; float y; public: Freshergate(int x) { x = x; } Freshergate(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 int main() { int val = 12; FresherGate objGate(val); FresherGate objTmp(); objGate.SetValue(val, 3.14f); objGate.Display(); return 0; } -
What will be the output of the following program?
#include struct GateArray { int arr[5]; public: void GateFunction(); void Display(); }; void GateArray::GateFunction() { static int i = 0, j = 4; i++; j--; if(j > 0) GateFunction(); int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i--; j++; } void GateArray::Display() { for(int i = 0; i 5; i++) cout" "; } int main() { GateArray objArr = {{5, 6, 3, 9, 0}}; objArr.GateFunction(); objArr.Display(); return 0; -
What will be the output of the following program?
#include#include class GateString { char x[50]; char y[50]; char z[50]; public: GateString() { } GateString(char* xx) { strcpy(x, xx); strcpy(y, xx); } GateString(char *xx, char *yy = " C++", char *zz = " Programming!") { strcpy(z, xx); strcat(z, yy); strcat(z, zz); } void Display(void) { coutint main() { GateString objStr("Learn", " Java"); objStr.Display(); return 0; } -
What will be the output of the following program?
#include class BaseCounter { protected: long int count; public: void CountIt(int x, int y = 10, int z = 20) { count = 0; cout" " " " 0; } BaseCounter(int x) { count = x ; } }; class DerivedCounter: public BaseCounter { public: DerivedCounter() { } DerivedCounter(int x): BaseCounter(x) { } }; int main() { DerivedCounter objDC(30); objDC.CountIt(40, 50); return 0; } -
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 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 } int main() { Number objNum(130); objNum.Modify(); return 0; } -
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" " 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; } -
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" " " " 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" " " "; Display(); } }; int main() { Derived objD; objD.Display(); return 0; } -
Which of the following statement is correct about the program given below?
#include static int Result; class Fresher { public: void Change(int x = 10, int y = 20, int z = 30) { coutvoid Display(int x = 40, float y = 50.00) { Result = x % x; coutclass Gate { int x, y; public: void Change(int x, int y = 50) { coutclass Freshergate: public Fresher, public Gate { public: void Display(int x = 10, int xx = 100, int xxx = 1000) { Result = x + xx % x * x; coutint main() { Fresher objGate; objGateFresher::Display(10, 20.00); return 0; } -
Which of the following statement is correct about the program given below?
#include class FresherGate { int x; float y; public: void GateFunction(int = 0, float = 0.00f, char = 'A'); void GateFunction(float, int = 10.00, char = 'Z'); void GateFunction(char, char, char); }; int main() { FresherGate objGate objGate.GateFunction(10 * 1.0, int(56.0)); return 0; } void FresherGate::GateFunction(int xx, float yy, char zz) { x = xx + int(yy); cout"x = " void FresherGate::GateFunction(float xx, int yy, char zz) { x = zz + zz; y = xx + yy; cout" x = "void FresherGate::GateFunction(char xx, char yy, char zz) { x = xx + yy + zz; y = float(xx * 2); cout" x = "
|
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. |
|
E.
The program will produce the output 66 65 infinite number of times (or till stack memory overflow). |

Whatsapp
Facebook