C++ Program: Functions Write a C++ function that will check if a character is a
ID: 3780072 • Letter: C
Question
C++ Program: Functions
Write a C++ function that will check if a character is a capital letter. You have the following steps:
main: prompt the user for a character and then enter the character
main: enter the character
main: call function your function sending the character to the function
yourfunname: test the character and return Boolean true if the character is a capital letter and false otherwise
main: display the Boolean value returned from the function
Note for the input of the function a character is sent to the function and a Boolean value is returned from the function.
Explanation / Answer
#include <iostream>
using namespace std;
bool check_caps(char ch)
{
return ch >= 'A' && ch <= 'Z';
}
int main()
{
char ch;
cout<<"Please enter a character:";
cin>>ch;
cout<<check_caps(ch)<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.