Docsity

Problems for Programming Using C - Assignment 3 | CGS 3460, Assignments of Computer Science

Toggle sidebar
bg1
CGS 3460 - Programming Using C
Fall 2008
Assignment #3
Assigned: Monday, Sept 8rd, 2008
Due: Monday, Sept 15th, 2008 at 11:59 PM
1. Write a program that formats the game information entered by the user. A session with the
program should look like this:
Enter home team: UF
Enter visitor: Miami
Enter game Day: (mm/dd): 09/06
Home Visitor Date
---- ------- ----
UF vs. Miami on 09/06/2008
You can assume team names are at most 5 characters. When you are reading from
user you must stop reading when you encounter ‘end-of-line’ or the fifth character,
whichever happens first. You will only get month and day information from user and append
year “2008” to the end when printing. The example above illustrates this behavior. When
printing; separate your columns with a ‘tab’ (\t) character so the corresponding fields in
rows are aligned. Save this program as p1.c.
2. Write a program that asks the user to enter an integer number (three-digits), and
then prints the number with its digits reversed and the product of all digits. A session
with the program should have the following appearance:
Enter an integer number: 148
The reversal is: 841
The product of digits is: 32
You don’t have to handle the case when user enters a number with more or less than
3 digits. Save this program as p2.c.
3. Write a C program that indicates which of the two given numbers is smaller. The
program should receive two float numbers as input from the user.
If two numbers are equal; the output should be “Entered numbers are
equal.”
If the first number is smaller; the output should be “The first number
is smaller”
If the second number is smaller; the output should be “The second
number is smaller”.
pf2

Partial preview of the text

Download Problems for Programming Using C - Assignment 3 | CGS 3460 and more Assignments Computer Science in PDF only on Docsity!

CGS 3460 - Programming Using C

Fall 2008

Assignment

Assigned: Monday, Sept 8rd, 2008

Due: Monday, Sept 15th, 2008 at 11:59 PM

1. Write a program that formats the game information entered by the user. A session with the

program should look like this: Enter home team: UF Enter visitor: Miami Enter game Day: (mm/dd): 09/ Home Visitor Date


UF vs. Miami on 09/06/ You can assume team names are at most 5 characters. When you are reading from user you must stop reading when you encounter ‘end-of-line’ or the fifth character , whichever happens first. You will only get month and day information from user and append year “2008” to the end when printing. The example above illustrates this behavior. When printing; separate your columns with a ‘tab’ (\t) character so the corresponding fields in rows are aligned. Save this program as p1.c.

2. Write a program that asks the user to enter an integer number (three-digits), and

then prints the number with its digits reversed and the product of all digits. A session with the program should have the following appearance: Enter an integer number: 148 The reversal is: 841 The product of digits is: 32 You don’t have to handle the case when user enters a number with more or less than 3 digits. Save this program as p2.c.

3. Write a C program that indicates which of the two given numbers is smaller. The

program should receive two float numbers as input from the user.

 If two numbers are equal; the output should be “ Entered numbers are

equal.”

 If the first number is smaller; the output should be “ The first number

is smaller ”

 If the second number is smaller; the output should be “ The second

number is smaller ”.

Save your program in a file called p3.c. Example 1: Enter Number 1: 32 Enter Number 2: - The second number is smaller. Example 2: Enter Number 1: 3 Enter Number 2: 3 Entered numbers are equal. Example 3: Enter Number 1: 13 Enter Number 2: 99 The first number is smaller. Instructions for submitting Assignment 3

  1. First compress your program files into a tar file. For this, change to the directory where you have stored both the files. At the terminal command prompt (putty, Linux console, MAC terminal, etc.) type:

    tar cvf assign3.tar p1.c p2.c p3.c Let’s say you have stored your files in assign3 directory your “rain” machine. cd assign ls p1.c p2.c p3.c .. tar cvf assign3.tar p1.c p2.c p3.c ls p1.c p2.c p3.c assign3.tar ….

  2. If you are working from Windows platform using Putty and WinSCP, you can create a directory assign3 in your home directory on rain machine using putty. Create the directory using this command on putty > cd //to change to the home directory > mkdir assign3 //to create the directory under home directory
  3. Then transfer p1.c, p2.c and p3.c to assign3 directory on rain using WinSCP.
  4. Go to step 1 to tar the file using putty.
  5. Use WinSCP to copy assign3.tar from rain machine back to your local computer, say desktop.
  6. Upload the assign3.tar to WebC