answersLogoWhite

0


Best Answer

#include<stdio.h> main() { char key; clrscr(); printf("Enter the key"); scanf("\n %c",& key); if (key>='A' key<='Z' )&&(key>='a' key<='z') { printf("%c is an character \n",key); } else { printf("%c is not character",key); } getch(); }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

6y ago

bool is_vowel (char c) { c = tolower (c);

if (c=='a') return true;

else if (c=='e') return true;

else if (c=='i') return true;

else if (c=='o') return true;

else if (c=='u') return true;

else

return false;

}

This is rather verbose and inefficient however the 'shorthand' version doesn't improve efficiency:

bool is_vowel (char c) {

c = tolower (c);

if (c=='a' c=='e' c=='i' c=='o' c=='u')

return true;

else

return false;

}

It is in inefficient because for the letter 'u' and all non-vowels we must perform 5 comparisons whereas 'a' requires just one comparison. However, the first version of the function is really just a thinly-veiled switch:

bool is_vowel (char c) { switch (tolower (c)) { case 'a': case 'e':

case 'i':

case 'o':

case 'u': return true;

default: return false;

}

}

Here, the compiler can optimise the code to produce an efficient jump table thus creating a constant-time operation regardless of whether the letter is a vowel or not. To understand how this works, a switch is really just a goto statement that accepts an integral value rather than a label, such that we jump to the default label when there is no matching label:

bool is_vowel (char c) { // Note: not valid in C!

goto tolower(c);

'a':

'e':

'i':

'o':

'u': return true;

default: return false;

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the C program to check whether a given character is vowel or not using if else?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program that stores vowels in an array When you program is given a character it should indicate whether the character is vowel or not?

That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


Write a C program to extract a given word from a file?

program to extract a given word from a file


How do you check whether a character is numeric in an alphanumeric field in C?

If the character's ASCII value is in the range of the digit characters, then it is a numeric. In ASCII, the range of digits is from '0' to '9' (48 to 57 decimal). Note that character constants such as '0' will implicitly convert to the constant integer 48 (the ASCII code for the character) so there is no need to remember the actual value; the compiler can determine this for us. The following function shows how one might test a character to see if it is a digit or not: bool is_digit (const char c) { return (c&gt;='0' &amp;&amp; c&lt;='9'); } The function will return true if the given character is a digit, otherwise it will return false.


How do you find whether a given number is even or odd in Unix shell programming?

echo "Program to check even or odd number"echo "Enter a number"read na=`expr $n % 2`if [ $a -eq 0 ] ; then #Semicolon is most important for Executing ifelse statementsecho "It is an even number"elseecho "It is an odd number"fi

Related questions

Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


Lab manual in mca 1st sem from ignou?

write a program in C to check whether a given number is apalindrome or not


To check whether the given number is an Avogadro number or not?

45


Write a program that stores vowels in an array When you program is given a character it should indicate whether the character is vowel or not?

That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.


Program to check whether the entered number is even or odd?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int n; printf("ENTER NO FOR CHECK........ "); scanf("%d", &amp;n); if(n%2==0) printf("Given No is EVEN"); else printf("Given No is ODD"); getch(); }


Draw a flow chart to check whether a given number is prime or not?

[object Object]


Shell program for gcd of three given numbers?

write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Write a Java Program to find occurences of given word in a text?

Check the documentation of the String class, for a method that searches for a substring.


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


Write a C program to extract a given word from a file?

program to extract a given word from a file


Who is awarded the Celtic cross?

This award is given in conjunction with the Presbyterian church and Scouting organisations. People who are awarded it are awarded it because they have demonstrated exceptional christian character, and/or have given faithful service to a youth program by serving in leadership positions.