Write C++ program to check vowel or consonant 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. char ch;
  8.  
  9. //Reading an alphabet from user
  10. cout<<"Enter any alphabet: ";
  11. cin>>ch;
  12.  
  13. // checking vowel and consonant
  14.  
  15. switch(ch)
  16. {
  17. case 'a': cout<<"vowel";
  18. break;
  19. case 'e': cout<<"vowel";
  20. break;
  21. case 'i': cout<<"vowel";
  22. break;
  23. case 'o': cout<<"vowel";
  24. break;
  25. case 'u': cout<<"vowel";
  26. break;
  27. case 'A': cout<<"vowel";
  28. break;
  29. case 'E': cout<<"vowel";
  30. break;
  31. case 'I': cout<<"vowel";
  32. break;
  33. case 'O': cout<<"vowel";
  34. break;
  35. case 'U': cout<<"vowel";
  36. break;
  37. default: cout<<"consonant";
  38. }
  39.  
  40. return 0;
  41.  
  42.  
  43. }
  44.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts