cpp-programming-functions Related Question Answers

26. What will be the output of the following program? #include<iostream.h> 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); cout<< TD.DriveIt() 10 << endl; return 0; }





27. What will be the output of the following program? #include<iostream.h> 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; }






28. 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; }





29. What will be the output of the following program? #include<iostream.h> class AreaFinder { float l, b, h; float result; public: AreaFinder(float hh = 0, float ll = 0, float bb = 0) { l = ll; b = bb; h = hh; } void Display(int ll) { if(l = 0) result = 3.14f h h; else result = l b; cout<< result; } }; int main() { AreaFinder objAF(10, 10, 20); objAF.Display(0); return 0; }





30. What will be the output of the following program? #include<iostream.h> class IndiaBix { public: int x, y; IndiaBix(int xx = 10, int yy = 20) { x = xx; y = yy; } void Exchange(int , int ); }; int main() { IndiaBix objA(30, 40); IndiaBix objB(50); objA.Exchange(&objA.x, &objB.y); cout<< objA.x << " " << objB.y << endl; return 0; } void IndiaBix::Exchange(int x, int y) { int t; t = x; x = y; y = t ; }






31. Which of the following statement is correct about the program given below? #include<iostream.h> class BixArray { int Matrix[3][3]; public: BixArray() { for(int i = 0; i<3; 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<< Matrix[j][i] << " "; } }; int main() { BixArray objBix; objBix.Display(); return 0; }





32. What will be the output of the following program? #include<iostream.h> 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; }






33. What will be the output of the following program? #include<iostream.h> #include<string.h> 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; }






34. Which of the following statement is correct about the program given below? #include<iostream.h> #include<string.h> #include<malloc.h> class BixString { char txtName[20]; public: BixString(char txtTemp = NULL) { if(txtTemp != NULL) strcpy(txtName, txtTemp); } void Display(void) { cout<<txtName; } }; int main() { char txtName = (char)malloc(10); strcpy(txtName, "IndiaBIX"); txtName = 48; BixString objTemp(txtName); cout<< sizeof(txtName); return 0; }






35. Which of the following statement is correct about the program given below? #include<iostream.h> 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; }






36. Which of the following statement is correct about the program given below? #include<iostream.h> class BixArray { int array[3][3]; public: BixArray(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<< array[i][j] << " "; } }; int main() { BixArray objBA; objBA.Display(); return 0; }





37. What will be the output of the following program? #include<iostream.h> 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; }





38. Which of the following statement is correct about the program given below? #include<iostream.h> 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; }





39. What will be the output of the following program? #include<iostream.h> 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; }






40. What will be the output of the following program? #include<iostream.h> #include<string.h> 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; }






41. What will be the output of the following program? #include<iostream.h> class BaseCounter { protected: long int count; public: void CountIt(int x, int y = 10, int z = 20) { count = 0; cout<< x << " " << y << " " << z << endl; } BaseCounter() { count = 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; }






42. What will be the output of the following program? #include<iostream.h> 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; }





43. What will be the output of the following program? #include<iostream.h> 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; }






44. What is correct about the following program? #include<iostream.h> 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; }






45. Which of the following statement is correct about the program given below? #include<iostream.h> static int Result; class India { public: void Change(int x = 10, int y = 20, int z = 30) { cout<< x + y + z; } void Display(int x = 40, float y = 50.00) { Result = x % x; cout<< Result; } }; class Bix { int x, y; public: void Change(int x, int y = 50) { cout<< x + y; } }; class IndiaBix: public India, public Bix { public: void Display(int x = 10, int xx = 100, int xxx = 1000) { Result = x + xx % x x; cout<< Result ; } }; int main() { IndiaBix objBix; objBix.India::Display(10, 20.00); return 0; }






46. Which of the following statement is correct about the program given below? #include<iostream.h> 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; }






47. Which of the following statement is correct about the program given below? #include<iostream.h> 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; }






48. What will be the output of the following program? #include<iostream.h> class Base { public: int S, A, M; Base(int x, int y) { S = y - y; A = x + x; M = x x; } Base(int, int y = 'A', int z = 'B') { S = y; A = y + 1 - 1; M = z - 1; } void Display(void) { cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { int x, y, z; public: Derived(int xx = 65, int yy = 66, int zz = 67): 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(-1); return 0; }






49. What will be the output of the following program? #include<iostream.h> 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; }






50. Which of the following function prototype is perfectly acceptable?





Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution