Programming Assigment 1 (Deadline: April 9 Thursday 23:59)
Problem
Write a program in C that computes
- the sum of the digits of a 4-digit positive integer,
- reverses a 5-letter word,
- and computes the square of a real number.
Input
Your program should read 3 lines of input from the terminal. The first line contains the 4-digit integer whose sum of digits is to be computed. The second line contains the 5-letter word which is to be reversed. The third line contains the real number whose square is to be computed.
Output
After reading the input, your program should output 3 lines. The first line must contain the sum of digits of the 4-digit number. The second line must contain the reversed 5-letter word. The third line should contain the square of the real number. The number in the last line must have exactly 4 digits after the decimal point.
All output is to the terminal. Make sure that your program does not output anything other than what is expected. In other words, when your program is fed with the sample input, its output should look exactly the same as the sample output.
Sample Input
6534
great
3.1
Sample Output(corresponding to the sample input)
18
taerg
9.6100
Assumptions and Constraints
You may safely assume that the first digit of the 4-digit input number will be larger than 0. You may safely assume that all letters of the word are lowercase english letters. You may safely assume that the real number does not have more than 2 decimal digits.
Submission
Submit your source code for the program (.c file) through the assignment submission system.(Wait for an e-mail about the assignment submission system.)
Hints
For the solution of this assignment, the mod operator (%) in C may be handy.