Write C++ program to find maximum number using switch case


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.


  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. int num1, num2;
  8.  
  9. //Reading two numbers from user
  10. cout<<"Enter two numbers to find maximum number: ";
  11. cin>>num1;
  12. cin>>num2;
  13.  
  14. //Condition to check maximum number
  15. switch(num1 > num2)
  16. {
  17. case 0: cout<<num2<<" is Maximum number";
  18. break;
  19.  
  20. case 1: cout<<num1<<" is Maximum number";
  21. break;
  22. }
  23.  
  24. return 0;
  25.  
  26. }
  27.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts