CPPForSchool.com: Library Function Set 1: Assignment 3

3. Write a program to check character entered is alphabet, digit or special character using library functions.


At this time, I am really pleased with my progress so far.  Perhaps it is because I am able to just dive into the assignment with little to no hesitation.  Nevertheless, for this assignment, I utilized the cctype library, specifically for isalpha and isdigit.  Although this may be a no-brainer, I wanted to clarify their use.  The function of isaplha determines if a character input is a letter, while isdigit determines if the character is a number.  Unfortunately, there is no "isspecialcharacter" function within cctype so I had to improvise. 

I went back and checked my notes on special character ASCII values and based the last condition on that, specifically within a nested if conditional statement inside the else statement.  When I compared my code to the sample source, I quickly discovered that I could have avoided the additional conditional statements altogether.  However, I do not regret my approach because it further solidifies my understanding of utilizing library functions a long with using int(c), which converts the character into the ASCII value.  Below is my source and output along with the sample source and output.











Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8