Write a C++ program that inputs a lower case character and converts it to an upp
ID: 648947 • Letter: W
Question
Write a C++ program that inputs a lower case character and converts it to an upper case character using the function below.
A character that is not a letter should be returned as is.
Character variables will need character trace tags.
Hint: characters only use one byte of storage and should be manipulated with byte instructions.
Add something to the output that makes this program uniquely yours.
Then translate it to Assembly language.
a) Cut and paste you C++ Source Code into your assignment document.
b) Comment lines of the source code to trace the C++ code. Cut & paste the Assembly Source Code Listing into your assignment document.
c) Run for 3 inputs: one uppercase, one lowercase, & one non-letter and paste a screen shot of each in the Output area of the PEP/8.
d) Step thru & Cut and paste the memory trace at a point when in uppercase subroutine.
char uppercase (char ch) {
if ((ch >= 'a') && (ch <= 'z')) { return ch - 'a' + 'A';
}
else
{
return ch; }
}
Explanation / Answer
#include <stdio.h>;
#include <ctype.h>;
int main()
{
int lower, upper;
lower = getchar();
upper = toupper(lower);
putchar(upper);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.