C++ Programming :: Functions - C++
-
What will be the output of the following program?
#include class TestDrive { int x; public: TestDrive(int xx) { x = xx; } int DriveIt(void); }; int TestDrive::DriveIt(void) { static int value = 0; int m; m = x % 2; x = x / 2; if((x / 2)) DriveIt(); value = value + m * 10; return value; } int main() { TestDrive TD(1234); cout10 return 0; } -
What will be the output of the following program?
#include class Freshergate { int Num; public: Freshergate(int x) { Num = x; } int GATEFunction(void); }; int Fresheragte: GATEFunction(void) { static int Sum = 0; int Dec; Dec = Num % 10; Num = Num / 10; if((Num / 100)) GateFunction(); sum = Sum * 10 + Dec; return Sum; } int main() { Fresheragate objGATE(12345); coutobjGATE.GATEFunctionreturn 0; } -
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) { coutint main() { Addition objA(15), objB; objB = objA + 5; objB.Display(); return 0; } -
What will be the output of the following program?
#include class Freshergate { public: int x, y; Freshergate(int xx = 10, int yy = 20) { x = xx; y = yy; } void Exchange(int *, int *); }; int main() { Freshergate objA(30, 40); Freshergate objB(50); objA.Exchange(&objA.x, &objB.y); cout" " return 0; } void Fresherate::Exchange(int *x, int *y) { int t; t = *x; *x = *y; *y = t ; } -
Which of the following statement is correct about the program given below?
#include classGATEArray { int Matrix[3][3]; public: GATEArray() { for(int i = 0; i3; i++) for(int j = 0; j 3; j++) Matrix[j][i] = i + j; } void Display(void) { for(int i = 0; i 3; i++) for(int j = 0; j 3; j++) cout" "; } }; int main() { GATEArray objBix; objGATE.Display(); return 0; } -
What will be the output of the following program?
#include class Freshergate { 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" " void SetValue(int xx, int yy) { Apply(xx, 0, yy); } }; int main() { Freshergate *pGate= new Freshergate; (*pGate).SetValue(12, 20); pGate->Display(); delete pGate; return 0; } -
What will be the output of the following program?
#include #include class Freshergate { char txtMsg[50]; public: Freshergate(char *str = NULL) { if(str != NULL) strcpy(txtMsg, str); } int GateFunction(char ch); }; int Freshergate::GateFunction(char ch) { static int i = 0; if(txtMsg[i++] == ch) return strlen((txtMsg + i)) - i; else return GateFunction(ch); } int main() { Freshergate objGate("Welcome to Freshergate.com!"); cout't'); return 0; } -
Which of the following statement is correct about the program given below?
#include #include #includeclass String { char txtName[20]; public: GateString(char *txtTemp = NULL) { if(txtTemp != NULL) strcpy(txtName, txtTemp); } void Display(void) { coutint main() { char *txtName = (char*)malloc(10); strcpy(txtName, "Freshergate"); *txtName = 48; GateString objTemp(txtName); coutsizeof(txtName); return 0; } -
Which of the following statement is correct about the program given below?
#includeclass Freshergate { int x, y, z; public: Freshergate(int x = 100, int y = 30, int z = 0) { this->x = x; this->y = y; this->z = z; Display(); } void Display() { cout" " " " int main() { int a = 0, b = 1, c = 2; int &x = ++a; int &y = --b; int z = c + b - -c; Freshergate objGate(x, y, z); return 0; } -
Which of the following statement is correct about the program given below?
#include class GateArray { int array[3][3]; public: GateArray(int arr[3][3] = NULL) { if(arr != NULL) for(int i = 0; i 3; i++) for(int j = 0; j 3; j++) array[i][j] = i+j; } void Display(void) { for(int i = 0; i 3; i++) for(int j = 0; j 3; j++) cout" "; } }; int main() { GateArray objBA; objBA.Display(); return 0; }

Whatsapp
Facebook