Question: #include using namespace std; 3 char symbols [ ] = SKQTRXP; 4 Bint functionOne(const char * s, int i) { 5 if (s[i] == '0')

 #include using namespace std; 3 char symbols [ ] = "SKQTRXP";4 Bint functionOne(const char * s, int i) { 5 if (s[i]

#include using namespace std; 3 char symbols [ ] = "SKQTRXP"; 4 Bint functionOne(const char * s, int i) { 5 if (s[i] == '\\0') return i; 6 return functionOne(s, ++i) ; 7 8 Bint functionTwo( char ch) { 9 int i = 0; 10 while (symbols [i] != '\\0' &&symbols [i++] != ch) ; 11 if ( symbols [i] == '\\0') return -1; 12 return - -i; 13 14 Elong int functionThree(int base, int pw) { 15 if (pw == 0) return 1; 16 return base * functionThree(base, pw - 1) ; 17 18 int functionFive(const char * str) { 19 int total = 0, len = functionOne(str, 0) ; 20 for (int i = 0; str[i] != '\\0';) { 21 total += functionTwo(str[i++])*functionThree(sizeof(symbols ) -1, len - i); 22 23 return total; 24 25 Bint main( ) { 26 char input [30]="KTX"; 27 cout #include #define PI 3. 1416 char shapeName [5] [30] = { "CIRCLE", "ELLIPSE", "RECTANGLE", "SQUARE", "DIAMOND" }; enum SHAPE_TYPE { CIRCLE = 0, ELLIPSE, RECTANGLE = 2, SQUARE = 3, DIAMOND 6 struct shape { SHAPE_TYPE stype; 8 double a; 9 double b; 10 char* name; 11 char* getTypeAsCString() { 12 return shapeName [ (int) stype ] ; 13 14 void setName (const char* sname) { 15 if (name != nullptr) delete[ ] name; 16 int len = 0; 17 while ( sname[len++] != '\\0' ); 18 name = new char [len ]; 19 int i = 0; 20 while (len- -) { name [i++] = sname[i]; } 21 22 shape(int t, double x, double y, const char * n) { 23 stype = (SHAPE_TYPE)t; 24 a = x; 25 b = y; 26 name = nullptr; 27 setName (n) ; 28 29 shape(int t, double x, double y) { 30 stype = (SHAPE_TYPE) t; 31 a = x; 32 b = y; 33 name = nullptr; 34 35 shape(int t) { 36 stype = (SHAPE_TYPE)t; 37 name = nullptr; 38 39 ~shape () { 40 if (name != nullptr) delete[ ] name; 41 42 43 double getArea (shape* s) { 44 double area = s->a * s->b; 45 switch (s->stype) { 46 case CIRCLE: return area * PI; 47 case ELLIPSE: return area * PI / 4; 48 case RECTANGLE : 49 case SQUARE: return area; 50 case DIAMOND: return area / 2; 51 default: return 0; 52 53 54 Evoid displayAllShapes (shape* d, int s) { 55 for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!