[SOLVED] ENCE260 Lab3 to 6 solution

80.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon ENCE260-feqpvd.zip (2809.6 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (1 vote)

[This program builds on the last one]
Write a program that loops, reading characters from standard input until EOF occurs. For each character read, a single
line of output should be printed as follows:
1. If the character is a new-line character (which has the value ‘\012’, i.e. 10 decimal), the printed line should be ‘\n’
(including the quotes). Otherwise …
2. The character itself should be printed, enclosed in single quotes followed by a colon and a space, followed by
either:
Digit <n> if the character represents one of the digits 0 through 9, where <n> is the represented digit, or
Letter <n> if the character is one of the letters ‘a’ through ‘z’ or ‘A’ through ‘Z’, in which case <n> is the ordinal
value of the letter, i.e. 1 for ‘a’ or ‘A’, 2 for ‘b’ or ‘B’ etc, or
Non-alphanumeric if the character is neither a digit nor a letter
Notes:
1. You may assume that no non-printing control characters (characters less than 32 decimal) other than newline are
present in the input. This is to save you worrying about the messed-up output that you’d get from characters like
Tab (‘\t’) and Return (‘\r’).
2. You will probably want to use various functions from ctype.h, such as isdigit and isalpha.
3. Remember that you can do arithmetic on characters so that ‘E’ – ‘D’ evaluates to 1.
4. Since backslash in printf format strings usually has a special meaning (as in ‘\n’ or ‘\012’), if you wish to print a
backslash you should ‘escape’ it with another backslash! For example, ‘printf(“\\Hi!\n”) prints the string “\Hi!”
followed by a newline.
For example:
Input Result
Go ENCE260!
End
‘G’: Letter 7
‘o’: Letter 15
‘ ‘: Non-alphanumeric
‘E’: Letter 5
‘N’: Letter 14
‘C’: Letter 3
‘E’: Letter 5
‘2’: Digit 2
‘6’: Digit 6
‘0’: Digit 0
‘!’: Non-alphanumeric
‘\n’
‘E’: Letter 5
‘n’: Letter 14
‘d’: Letter 4
‘\n’

  • ENCE260-feqpvd.zip