CSCI 151: Introduction to Computer Science - Fall 2009
Lab 3

  
Objectives:
practice with basic LINUX commands,
integer arithmetic in C;
compiling and executing C code.   
Lab 3 includes Practice Part and Assignment Part.
Assignment part you will need to submit at the end of the lab.
Assignment part will be handed out in class after we will finish the Practice Part.
Lab Practice:

In this part you will write a few programs. We will work according to the following plan:

Important:

  • Start your program with comments part that includes:
  • In all programs you have to explain what is the meaning of the results that your program is printing. Don't print numbers without any explanation!
  • If you wrote the program before solution is posted, you can show me the resullt and start to write the next program. You don't need to wait for the solution! You can continue with the next program!
  • Please, follow the directions! Keep the names of the files according to the directions! Make sure that you are in the right directory!
    Part I: Practice Part
    1. Login to the system using your login name and the password
    2. Change to your CSCI151 directory: cd CSCI151
    3. Create a new directory lab3 under your CSCI151 directory: mkdir lab3.
    4. Change to lab3 directory cd lab3
    5. All program that you will write in the Pratice Part will be saved in the directory lab3 .

    6. Program 1 :

      • Open emacs by typing the following at the LINUX prompt
        emacs prodDig.c &
      • In the file prodDig.c write a C program that prompts the user to enter one positive 3-digits integer and finds and prints the product of the digits of the input number.
      • After you finished writing , compile and run your program to check that your program returns a correct output. Run your program a few times with different inputs to test the corectness of the output.
      • Show me the result

    7. Program 2:
      • Open emacs by typing the following at the LINUX prompt
        emacs reverse.c &
      • In the file reverse.c write a C program that prompts the user to enter one positive 4-digits integer. The program finds and prints the everage of the digits and prints the digits of the input number in reverse order with the space between digits. For example, if the input is 2348, the output should be:
        average of the digits is: 4
        the digits in reverse order are: 8 4 3 2.
      • Compile and run your program with different inputs
      • Show me the result

    8. DO THE ASSIGNMENT PART!

    9. Have a good evening.