One of the things you will notice about this program is that it is not documente
ID: 647702 • Letter: O
Question
One of the things you will notice about this program is that it is not documented with comments for the algorithm or for the functions. Your first task is to document this code. Copy the program into myreadcmd.c, and extend this file to ignores leading tabs as well as leading blanks (or any combinations of blanks and tabs). Now extend the program to have either a semi-colon or a newline character indicate the end of a command. Here's a sample run:
Now extend the program to verify that the command is an upper or lower case letter. It should print an error message if it isn't. Also, verify that the line has a command: if it hits a blank or ; without an intervening command, you should print an error. Here's a sample run:
Explanation / Answer
// to know if letter is uppercase or lowercase or not a letter
void uppercase(int c)
{
if (c >= 65 && c <=90)
{
printf("Command is in upper case");
printf("command is %c", c);
}
else if (c >= 'a' && c <= 'z')
{
printf("Command is in lower case");
printf("command is %c", c);
}
else
prinf ("%c is not a command", c);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.