Problem Solving: Detecting Letter Casing
Learn to write a program to check letter casing using functions.
We'll cover the following
In this lesson, we will learn to check if a letter is small or capital using functions.
Capital or small letter
Take a character input from the user and determine whether the character is a capital letter or a small letter.
Sample input
A
Sample output
Capital letter
Although we discussed this problem in the “Memory, Operations, and Control Structure” chapter. we will solve the same problem here using functions.
So let’s say we have a symbol
variable as char
input and we need to determine whether it is a capital or small letter. We will create a function charType()
that takes symbol
as a parameter and returns an integer based on whether the letter is small or capital. If it’s capital, our program will return 1
; if it’s small, it’ll return 2
; otherwise, it’ll return 3
.
Get hands-on with 1200+ tech skills courses.