Write C++ program to print gender Male Female program


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. char gender;
  8.  
  9. //Reading gender from user
  10. cout<<"Enter gender (M/m or F/f): ";
  11. cin>>gender;
  12.  
  13. switch(gender)
  14. {
  15. case 'M':
  16. case 'm':
  17. cout<<"Male";
  18. break;
  19. case 'F':
  20. case 'f':
  21. cout<<"Female";
  22. break;
  23. default:
  24. cout<<"Unspecified Gender"<<endl;
  25. }
  26.  
  27. return 0;
  28.  
  29. }
  30.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts