Results 1 to 8 of 8

Thread: Program for vowel using logical operator in C++

  1. #1
    Abidalicu's Avatar
    Abidalicu is offline Senior Member+
    Last Online
    4th November 2017 @ 04:39 PM
    Join Date
    17 Aug 2014
    Location
    Peshawar
    Gender
    Male
    Posts
    85
    Threads
    12
    Credits
    514
    Thanked
    4

    Default Program for vowel using logical operator in C++

    //Program for vowel using logical operator by Abid Ali

    #include<iostream>
    using namespace std;
    int main()
    {
    char ch;

    cout<<"Enter a character\n";
    cin>>ch;

    if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
    cout<<"character is a vowel.\n";
    else
    cout<<"character is not a vowel.\n";
    return 0;
    }

  2. #2
    The Rocket is offline Member
    Last Online
    11th May 2015 @ 02:44 PM
    Join Date
    27 Mar 2015
    Age
    23
    Gender
    Male
    Posts
    1,137
    Threads
    82
    Thanked
    96

    Default

    great share with us

  3. #3
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 11:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Thanked
    5

    Default

    Quote Abidalicu said: View Post
    //Program for vowel using logical operator by Abid Ali

    #include<iostream>
    using namespace std;
    int main()
    {
    char ch;

    cout<<"Enter a character\n";
    cin>>ch;

    if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
    cout<<"character is a vowel.\n";
    else
    cout<<"character is not a vowel.\n";
    return 0;
    }
    Good, but I think Switch-Statement is better than if-else in this case.

    So, see this one.

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
        char character;
    
        cout << "Enter a character:- ";
        cin >> character;
    
        switch (character)
        {
        case 'A':
        case 'a':
        case 'E':
        case 'e':
        case 'I':
        case 'i':
        case 'O':
        case 'o':
        case 'U':
        case 'u':
            cout << "Character is a vowel\n";
            break;
        default:
            cout << "Character is not a vowel\n";
        }
    
        return 0;
    }

  4. #4
    Abidalicu's Avatar
    Abidalicu is offline Senior Member+
    Last Online
    4th November 2017 @ 04:39 PM
    Join Date
    17 Aug 2014
    Location
    Peshawar
    Gender
    Male
    Posts
    85
    Threads
    12
    Credits
    514
    Thanked
    4

    Default

    Quote Z.Programmer said: View Post
    Good, but I think Switch-Statement is better than if-else in this case.

    So, see this one.

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
        char character;
    
        cout << "Enter a character:- ";
        cin >> character;
    
        switch (character)
        {
        case 'A':
        case 'a':
        case 'E':
        case 'e':
        case 'I':
        case 'i':
        case 'O':
        case 'o':
        case 'U':
        case 'u':
            cout << "Character is a vowel\n";
            break;
        default:
            cout << "Character is not a vowel\n";
        }
    
        return 0;
    }
    yup bro but its just for learning purpose once you learn then its depend on you what method you like to follow

  5. #5
    hassaan_haris's Avatar
    hassaan_haris is offline Senior Member+
    Last Online
    28th May 2017 @ 09:37 PM
    Join Date
    09 Feb 2009
    Posts
    72
    Threads
    1
    Credits
    413
    Thanked: 1

    Default

    بہت اچھا سمجھایا آپ نے، اصل چیز سمجھنا ہے، طریقے بہت سارے استعمال ہوسکتے ہیں۔
    اگر اسکریین شاٹ بھی دیتے تو اچھا تھا
    شکریہ

  6. #6
    Bindass666 is offline Senior Member+
    Last Online
    9th December 2017 @ 07:37 PM
    Join Date
    13 May 2011
    Age
    24
    Gender
    Male
    Posts
    125
    Threads
    0
    Credits
    787
    Thanked
    7

    Default

    Quote Abidalicu said: View Post
    //Program for vowel using logical operator by Abid Ali

    #include<iostream>
    using namespace std;
    int main()
    {
    char ch;

    cout<<"Enter a character\n";
    cin>>ch;

    if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
    cout<<"character is a vowel.\n";
    else
    cout<<"character is not a vowel.\n";
    return 0;
    }
    salam.... de c++ ki sa grapics wagera na ye ka da daga shan ye...??? layout dapara pake kam yo soft use kege???

  7. #7
    Abidalicu's Avatar
    Abidalicu is offline Senior Member+
    Last Online
    4th November 2017 @ 04:39 PM
    Join Date
    17 Aug 2014
    Location
    Peshawar
    Gender
    Male
    Posts
    85
    Threads
    12
    Credits
    514
    Thanked
    4

    Default

    Quote Bindass666 said: View Post
    salam.... de c++ ki sa grapics wagera na ye ka da daga shan ye...??? layout dapara pake kam yo soft use kege???
    visual C++ deko to app ko sab kuch samj ajay ga..
    The Prophet(SAW) said: "Acquire knowledge and impart it to the people."

  8. #8
    Bindass666 is offline Senior Member+
    Last Online
    9th December 2017 @ 07:37 PM
    Join Date
    13 May 2011
    Age
    24
    Gender
    Male
    Posts
    125
    Threads
    0
    Credits
    787
    Thanked
    7

    Default

    Quote Abidalicu said: View Post
    visual C++ deko to app ko sab kuch samj ajay ga..
    Shukriya bhai

Similar Threads

  1. program plz 4
    By PREMkhan in forum Ask an Expert
    Replies: 1
    Last Post: 26th May 2010, 12:53 AM
  2. Solved plz help me in the following c++ program
    By raza89 in forum Solved Problems (IT)
    Replies: 4
    Last Post: 19th October 2009, 09:29 AM
  3. Share ur Eid Program
    By ussmaan in forum Baat cheet
    Replies: 3
    Last Post: 21st September 2009, 01:46 AM
  4. Replies: 8
    Last Post: 19th May 2009, 06:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •