#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(); }
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;
}
That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.
/*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 (); }
program to extract a given word from a file
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>='0' && c<='9'); } The function will return true if the given character is a digit, otherwise it will return false.
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
8086 assembly language program to check wether given number is perfect or not
write a program in C to check whether a given number is apalindrome or not
45
That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.
#include<stdio.h> #include<conio.h> void main() { int n; printf("ENTER NO FOR CHECK........ "); scanf("%d", &n); if(n%2==0) printf("Given No is EVEN"); else printf("Given No is ODD"); getch(); }
[object Object]
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
Type your answer here... i think we should first enter 1 number then check it
Check the documentation of the String class, for a method that searches for a substring.
/*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 (); }
program to extract a given word from a file
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.