I write letter, it checks vowel or not
but could not achieve for the capital letter without using if loop
help me

#include <cstdlib>
#include <iostream>
#include "stdio.h"
#include "conio.h"
#include "string.h"

using namespace std;
int main(int argc, char *argv[])
{
int a,b;
char ch;
printf("Enter Letter=");
scanf("%c",&ch);
if (ch==a)

printf("vowel");
else
if (ch=='a')
printf("vowel");
else
if (ch=='e')
printf("vowel");
else
if (ch=='i')
printf("vowel");
else
if (ch=='o')
printf("vowel");
else
if (ch=='u')
printf("vowel");
else
printf("not vowel");
getch();   
    system("PAUSE");
    return EXIT_SUCCESS;
}

Recommended Answers

All 2 Replies

In your if's you need to change it to if (ch == <vowel> || ch==<capital vowel>).The "||" operator means logical or.

You can also use the tolower(ch) function to make sure uppercase letters are seen as lowercase ones, then you can do something like this

switch( tolower(ch) )
{
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
        printf("vowel");
        break;
    case 'y':
        printf("may be vowel");
        break;
    default:
        printf("not vowel");
        break;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.