fork(1) download
  1. //namespace calculator(lab1-task1)
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. namespace calculator{
  6. namespace addition{
  7. int add(int x,int y){
  8. return (x+y);
  9. }
  10.  
  11. }
  12. namespace subtraction{
  13. int subs(int x,int y){
  14. return (x-y);
  15. }
  16.  
  17. }
  18. namespace multiplication{
  19.  
  20. int muiti(int x,int y){
  21. return (x*y);
  22.  
  23. }
  24. }
  25. namespace dividation{
  26. float div(int x,float y){
  27. if(y!=0)return x/y;
  28. else{
  29. cout<<"NOT possible"<<endl;
  30.  
  31. }
  32. }
  33.  
  34. }
  35.  
  36.  
  37. }
  38.  
  39.  
  40.  
  41. int main ()
  42. {
  43. int x, y;
  44. cout<<"Enter your digits : ";
  45. cin>>x>>y;
  46. cout<<"summation of numbers are : "<<calculator::addition::add(x,y)<<endl;
  47. cout<<"subtraction of numbers are : "<<calculator::subtraction::subs(x,y)<<endl;
  48. cout<<"multiplication of numbers are : "<<calculator::multiplication::muiti(x,y)<<endl;
  49. cout<<"division of numbers are : "<<calculator::dividation::div(x,y)<<endl;
  50. return 0;
  51. }
  52.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter your digits  : summation of numbers are : -409868514
subtraction of numbers are : -409934046
multiplication of numbers are : -462605888
division of numbers are : -12510