Docsity

Assignment I - Programming Using C | CGS 3460, Assignments of Computer Science

Toggle sidebar
bg1
CGS 3460 - Programming Using C
Summer 2009
Assignment #1
Assigned: 05/13/2009, Fri
Due: 05/19/2009, Tue, 11:59 PM
1. (5 Points) Write a program to print ASCII art version of your last name. Save your
program in a file called p1.c
Example: If your last name is Fisher, you can print it as follows:
______ _ _
| ___(_) | |
| |_ _ ___| |__ ___ _ __
| _| | / __| '_ \ / _ \ '__|
| | | \__ \ | | | __/ |
\_| |_|___/_| |_|\___|_|
You can use the web site: http://www.network-science.de/ascii/ to create ASCII art from
text. The example above is created using font 'doom’. You can pick any font you like but
put the font name into comments.
2. (5 Points) Write a program that reads in two integers and outputs their sum,
difference, and product. In addition it should tell whether each input value is odd. It
should display a 1 if it is odd and and 0 if it is even. Save this as p2.c
Example 1:
>Enter two integers: 23 34
The sum of 23 and 34 is 57
The difference of 23 and 34 is -11
The product of 23 and 34 is 782
23 is odd: 1
34 is odd: 0
Example 2:
>Enter two integers: -10 20
The sum of -10 and 20 is 10
The difference of -10 and 20 is -30
The product of -10 and 20 is -200
-10 is odd: 0
20 is odd: 0
pf2

Partial preview of the text

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

CGS 3460 - Programming Using C

Summer 2009

Assignment # Assigned: 05/13/2009, Fri Due: 05/19/2009, Tue, 11:59 PM

  1. (5 Points) Write a program to print ASCII art version of your last name. Save your program in a file called p1.c Example: If your last name is Fisher, you can print it as follows:

| () | | | | _ | | ___ _ __ | | | / | ' \ / _ \ '| | | | _ \ | | | / | _| ||/| ||_|| You can use the web site: http://www.network-science.de/ascii/ to create ASCII art from text. The example above is created using font 'doom’. You can pick any font you like but put the font name into comments.

  1. (5 Points) Write a program that reads in two integers and outputs their sum, difference, and product. In addition it should tell whether each input value is odd. It should display a 1 if it is odd and and 0 if it is even. Save this as p2.c Example 1:

    Enter two integers: 23 34 The sum of 23 and 34 is 57 The difference of 23 and 34 is - The product of 23 and 34 is 782 23 is odd: 1 34 is odd: 0 Example 2: Enter two integers: -10 20 The sum of -10 and 20 is 10 The difference of -10 and 20 is - The product of -10 and 20 is - -10 is odd: 0 20 is odd: 0

  1. (5 Points) Write a program which reads in 5 floating point values from the user and displays the given values in a vertical column. Each number should be displayed with an accuracy of two decimal places and the decimal points should be made to line up

vertically. (Hint: the maximum magnitude of a floating point number is ±3.4×10^38 .)

Save this as p3.c

  1. (5 Points) Write a program which will read in two fractions (such as 3/7) and then print each fraction and their sum and product as fractions. You don't have to reduce fractions to their simplest form. Save this as p4.c Instructions for submitting Assignment 1
  2. 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 assign1.tar p1.c p2.c p3.c p4.c Let’s say you have stored your files in assign1 directory on your “rain” machine.

cd assign ls p1.c p2.c p3.c p4.c .. tar cvf assign1.tar p1.c p2.c p3.c p4.c ls p1.c p2.c p3.c p4.c assign1.tar ….

  1. If you are working from Windows platform using Putty and WinSCP, you can create a directory assign1 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 assign1 //to create the directory under home directory

  2. Then transfer p1.c, p2.c, p3.c and p4.c to assign1 directory on rain using WinSCP.
  3. Go to step 1 to tar the file using putty.
  4. Use WinSCP to copy assign1.tar from rain machine back to your local computer, say desktop.
  5. Upload the assign1.tar to WebCT.
  6. Please check the discussion page for assignment 1 on WebCT for common questions and their answers.