0% found this document useful (0 votes)
19 views2 pages

C++ Case Conversion Program Guide

Uploaded by

musasal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

C++ Case Conversion Program Guide

Uploaded by

musasal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SECTION: 1-B (DEPT.

of COMPUTER SCIENCE)
DATE: 25TH Nov 2023
Exercises/Lab Journal 9

Task 1: Write a C++ program with two functions U_Case( ) and L_Case( ), that
takes an alphabet from the user and display it in the other case i.e. if the user enters
an alphabet in lower case it should call U_Case( ) and convert it to uppercase and
then display it and incase the user enters an alphabet in uppercase it should call
L_Case().

HINT: You may use functions defined in <cctype> header file. To identify
the functions your need, visit following URL
(https://cplusplus.com/reference/cctype/) and read the documentation. To
use the function include following header file #include <cctype>
CODE:
#include <iostream>
#include <cctype> //this header file declares a set of function to classify and convert different individual characers
using namespace std;
int main()
{
char alphabet; //datatype character
cout << "enter an alphabet" << endl;
cin >> alphabet;
char case_change;

if (islower(alphabet)) //statement or condition says that if the alphabet is in lower case, then
{
case_change = toupper(alphabet); //convert it to upper case
cout << "lower case alphabet will be " << case_change << " in upper case" << endl; //display the
converted alphabet
}
if (isupper(alphabet)) //statement or condition says that if the alphabet is in upper case, then
{
case_change = tolower(alphabet); //convert it to lower case
cout << "upper case alphabet will be " << case_change << " in lower case" << endl; //display the
converted alphabet
}

Output:

From lower (small letters) to upper case (capital or bold letters)

From upper (capital/bold) to lower case (small letters)

You might also like