All character functions in C++
#include<iostream> #include<conio.h> using namespace std; int isUpper(char ch) { if(ch>=65&&ch<=90) return 1; else return 0; } int isLower(char ch) { if(ch>=97&&ch<=122) return 1; else return 0; } int isDigit(char ch) { if(ch>=48&&ch<=57) return 1; else return 0; } int isAlph(char ch) { if(ch>=97&&ch<=122||ch>=65&&ch<=90) return 1; else return 0; } int isAlnum(char ch) { if(ch>=97&&ch<=122||ch>=65&&ch<=90||ch>=48&&ch<=57) return 1; else return 0; } int isBlank(char ch) { if(ch==' '||ch=='\t') return 1; else return 0; } char toUpper(char ch) { ch=ch-32; return ch; } char toLower(char ch) { ch=ch+32; return ch; } int isSpace(char ch) { if(ch==' '||ch=='\t') return 1; else return 0; } int isCntrl(char ch) { if(ch=='\n'||ch=='\t'||ch=='\r'||ch=='\a') return 1; else return 0; } int main() { if(isLower('c')) cout<<"Charater is lower."; else cout<<"Charater is Not lower."; if(isAlnum('8')) cout<<"\nAlphanumeric character."; else cout<<"\nNot alphanumeric character."; char ch='\a'; if(isCntrl(ch)) cout<<"\nControl character"; else cout<<"\nNot Control character"; if(isBlank(' ')) cout<<"\nBlank space."; else cout<<"\nNot Blank space."; }
Output:-
0 Comments