fork download
  1.  
  2. class Arith
  3. {
  4. private:
  5. int x,y;
  6. public:
  7. int add();
  8. int sub();
  9. int mul();
  10. int div();
  11. };
  12. int Arith::add()
  13. {
  14. cout<<"Enter the x value"<<endl;
  15. cin>>x;
  16. cout<<"Enter the y value"<<endl;
  17. cin>>y;
  18. return(x+y);
  19. }
  20. int Arith::sub()
  21. {
  22. cout<<"Enter the x value"<<endl;
  23. cin>>x;
  24. cout<<"Enter the y value"<<endl;
  25. cin>>y;
  26. return(x-y);
  27. }
  28. int Arith::mul()
  29. {
  30. cout<<"Enter the x value"<<endl;
  31. cin>>x;
  32. cout<<"Enter the y value"<<endl;
  33. cin>>y;
  34. return(x*y);
  35. }
  36. int Arith::div()
  37. {
  38. cout<<"Enter the x value"<<endl;
  39. cin>>x;
  40. cout<<"Enter the y value"<<endl;
  41. cin>>y;
  42. return(x/y);
  43. }
  44. main()
  45. {
  46. Arith obj;
  47. char ch;
  48. clrscr();
  49. while(1)
  50. {
  51. cout<<"a:Addition"<<endl;
  52. cout<<"s:Subtraction"<<endl;
  53. cout<<"m:Multiply"<<endl;
  54. cout<<"d:Division"<<endl;
  55. cout<<"e:exit"<<endl;
  56. cout<<"Enter your Choice"<<endl;
  57. cin>>ch;
  58. switch(ch)
  59. {
  60. case 'a':
  61. int a=obj.add();
  62. cout<<"Addtion Result="<<a<<endl;
  63. break;
  64. case 's':
  65. int s=obj.sub();
  66. cout<<"Subtract Result="<<s<<endl;
  67. break;
  68. case 'm':
  69. int m=obj.mul();
  70. cout<<"Multiply Result="<<m<<endl;
  71. break;
  72. case 'd':
  73. int d=obj.div();
  74. cout<<"Division Result="<<d<<endl;
  75. break;
  76. case 'e':
  77. exit(0);
  78. }
  79. }
  80. getch();
  81. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
50 
5
e
compilation info
prog.cpp: In member function ‘int Arith::add()’:
prog.cpp:14:5: error: ‘cout’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
     ^~~~
prog.cpp:14:32: error: ‘endl’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
                                ^~~~
prog.cpp:15:5: error: ‘cin’ was not declared in this scope
     cin>>x;
     ^~~
prog.cpp: In member function ‘int Arith::sub()’:
prog.cpp:22:5: error: ‘cout’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
     ^~~~
prog.cpp:22:32: error: ‘endl’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
                                ^~~~
prog.cpp:23:5: error: ‘cin’ was not declared in this scope
     cin>>x;
     ^~~
prog.cpp: In member function ‘int Arith::mul()’:
prog.cpp:30:5: error: ‘cout’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
     ^~~~
prog.cpp:30:32: error: ‘endl’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
                                ^~~~
prog.cpp:31:5: error: ‘cin’ was not declared in this scope
     cin>>x;
     ^~~
prog.cpp: In member function ‘int Arith::div()’:
prog.cpp:38:5: error: ‘cout’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
     ^~~~
prog.cpp:38:32: error: ‘endl’ was not declared in this scope
     cout<<"Enter the x value"<<endl;
                                ^~~~
prog.cpp:39:5: error: ‘cin’ was not declared in this scope
     cin>>x;
     ^~~
prog.cpp: In function ‘int main()’:
prog.cpp:48:12: error: ‘clrscr’ was not declared in this scope
     clrscr();
            ^
prog.cpp:51:5: error: ‘cout’ was not declared in this scope
     cout<<"a:Addition"<<endl;
     ^~~~
prog.cpp:51:25: error: ‘endl’ was not declared in this scope
     cout<<"a:Addition"<<endl;
                         ^~~~
prog.cpp:57:5: error: ‘cin’ was not declared in this scope
     cin>>ch;
     ^~~
prog.cpp:64:14: error: jump to case label [-fpermissive]
         case 's':
              ^~~
prog.cpp:61:21: note:   crosses initialization of ‘int a’
                 int a=obj.add();
                     ^
prog.cpp:68:14: error: jump to case label [-fpermissive]
         case 'm':
              ^~~
prog.cpp:65:21: note:   crosses initialization of ‘int s’
                 int s=obj.sub();
                     ^
prog.cpp:61:21: note:   crosses initialization of ‘int a’
                 int a=obj.add();
                     ^
prog.cpp:72:14: error: jump to case label [-fpermissive]
         case 'd':
              ^~~
prog.cpp:69:21: note:   crosses initialization of ‘int m’
                 int m=obj.mul();
                     ^
prog.cpp:65:21: note:   crosses initialization of ‘int s’
                 int s=obj.sub();
                     ^
prog.cpp:61:21: note:   crosses initialization of ‘int a’
                 int a=obj.add();
                     ^
prog.cpp:76:14: error: jump to case label [-fpermissive]
         case 'e':
              ^~~
prog.cpp:73:21: note:   crosses initialization of ‘int d’
                 int d=obj.div();
                     ^
prog.cpp:69:21: note:   crosses initialization of ‘int m’
                 int m=obj.mul();
                     ^
prog.cpp:65:21: note:   crosses initialization of ‘int s’
                 int s=obj.sub();
                     ^
prog.cpp:61:21: note:   crosses initialization of ‘int a’
                 int a=obj.add();
                     ^
prog.cpp:77:23: error: ‘exit’ was not declared in this scope
                 exit(0);
                       ^
prog.cpp:80:11: error: ‘getch’ was not declared in this scope
     getch();
           ^
stdout
Standard output is empty