Starting from:

$35

CSC60- Lab 1: The First Program Solved

GOAL:  Learn the procedure to enter a program, compile and build it, and get it to work.  Most of this will be needed ALL semester for almost every assignment.

 STEP 1:  GETTING STARTED  – get an account .  

You may need to turn the screen on. Log on with your ECS account.  If you do not have one yet:

1.      Open a browser

2.      Go to http://www.ecs.csus.edu/index.php?content=accounts

3.      Under Section Request or Modify, click on Apply for a new ECS account (Windows/Unix)

4.      Follow the directions.

You will receive an email when the account is ready. You (with your One Card) can pick up the paperwork from the lab assistant in RVR-2011.

LOGGING ON TO Athena:

 STEP 2a:  Turn on an ECS computer & log in to  athena . 

Labs:  RVR-2011, RVR-2013 (when it has no class in it), SCL-1208, SCL-1234.

Log in with your account.  Lots of windows will scroll by. Wait for them to clear.

Click on the Start Button in the lower left of the screen.

In the Search box, type PuTTY.

Click on PuTTY (in the Programs list).

The PuTTY window will open.

In the box labeled Host Name, type athena.ecs.csus.edu Click on Open (lower right of the window).  

You will get a window to athena with a prompt to “Log in as”.

Enter your User Name.  

Enter your Password. (Nothing will show on the screen as you type it.) You will now have a prompt such as the one I got:  [bielr@athena ~]>

STEP 2b: Logging in from home on a Windows machine.

Download PuTTY or another terminal program to your computer.

Open PuTTY.

In the box labeled Host Name, type athena.ecs.csus.edu Click on Open (lower right of the window).  

You will get a window to athena with a prompt to “Log in as”.

Enter your User Name.  

Enter your Password. (Nothing will show on the screen as you type it.) You will now have a prompt similar to the one I got:  [bielr@athena ~]>

STEP 2c: Logging in from home on a Mac machine.

Open up a terminal/console window and type one of the following:             ssh yourECSname@athena.ecs.csus.edu Press Enter.

When prompted, type “yes” to accept the server’s key.

Then enter your password. (Nothing will show on the screen as you type it.)

STEP 2d: Using hydra

Log into hydra from Windows home computer and pretend like you are on campus From Windows, bring up the Remote Desktop Connection software. In the box labeled “computer”, enter:  hydra.esc.csus.edu Refer to Step 2a above to get to athena.

Log into hydra from MAC home computer and pretend like you are on campus. There is information of the ECS website that explains how to find hydra on your mac. Below are two choices for getting to the same information. Refer to Step 2a above to get to athena.

Use the following link for directions for the software and its use:

https://www.ecs.csus.edu/computing/help_docs/Connecting_to_Hydra-Mac.pdf

STEP 3:  GETTING SET UP TO START You should now be logged into athena.

Create a directory (subfolder) for this class by typing:  mkdir csc60

Change to the new folder by typing:  cd csc60

Create a directory for this assignment by typing:  mkdir lab1 Change to the new folder by typing:  cd lab1

STEP 4:  START ENTERING YOUR PROGRAM.

At the prompt “>”, type vim lab1.c

Go into insert mode by typing:  i     

Start typing in your program in this window.  

For this Lab1, enter in the program that appears below inside the box below.

(PS: You don’t have to create the box.)

Type your own full name (both first and last) in all the places needed.

Start typing at the left edge of the screen.  

Use the indentation style as shown.  

Attribution for the quote is required. You may print  the quote & attribution in one printf or two.

 more on next page

Teacher Comments:

                                     

                                                                   Don’t count the dashes. Approximate.

                                                                  Put Your-Name here, both  first & last   

                                                                   "/*    */" = comment symbol                            

                                                                  {Preprocessing directives for

                                                                  {the compiler.                              

                                                                   Line required in each program.

   

Be sure to indent for clarity            Put your First & Last name here!

Put your quote here instead of the word “quote”

/*-------------------------*/        

/* Your Name Here   */        

/* Lab 1                       */        

                                                              

#include <stdio.h>                   

#include <stdlib.h>                  

                                                             

int main (void)                      

{                                                         

        printf("\nLab 1. \n\n");           printf(“Hello World.\n”);                printf("Hi, Your Name. \n\n");         printf("quote \n\n");     

        return EXIT_SUCCESS;              

}                                                         

/*-------------------------*/      
                                                                            Attribution for the quote is required.

Capitalize EXIT_SUCCESS

   

   

5:  SAVE YOUR WORK, COMPILE IT, AND SEE THE RESULTS.

Get out of insert mode by typing:  Esc   (escape key) To save your work and quit, type:  :wq The shell prompt returns.

Type:  gcc lab1.c   (This compiles the program and sends the output to a file called a.out) If you have compile errors, they will appear, and they will need to be fixed. The prompt returns.

If you have no errors, type a.out and the output of your program will display. The results of my program appear below.

[bielr@athena ~/csc60]34> a.out

Lab 1.

Hello World.

Hi, Ruthann Biel.

Be yourself; everyone else is already taken.
- Oscar Wilde                                                                NOTICE the attribution for the quote is                                                                                         required.

[bielr@athena ~/csc60]35>
Comments:  Your instructor is picky about presentation.  There should be an empty line between a.out and Lab 1, and again at the end before the prompt returns.  I expect your output to have empty lines where they show above.  Use proper English and proper punctuation in your quote. Save your creativity for the quote.

To show your line numbers in VIM:

1.      Press the Esc key if you are currently in insert or append mode.

2.      Type the : (colon). The cursor should reappear at the lower left corner of the screen next to a colon (:) prompt.

3.      After the colon, enter the following command: set number

4.      A column of sequential line numbers will then appear at the left side of the screen.

If you have Errors:

If you have errors, it is OK, a normal course of events.  Examine the Error Message list.  Sometimes the second or third message makes more sense than the first error message.  One code error can cause SEVERAL error messages.

 

Fix your errors, and save your changes.  Go back to the top of STEP 5. Repeat until you have NO ERRORS.

                                                             MAJOR REMINDER.                                                      

      Every time you change the code, you must redo the COMPILE (which is the gcc       line) before you run the program, or you will NOT see any changes when you       run the program. !!!                                        
STEP 6.  PREPARE YOUR FILE FOR GRADING.

When all is well and correct, and you are still on athena,

•      type:  script StudentName_lab1.txt       Script will keep a log of your session.

    Please use Your name instead of “StudentName”     Use your first and last name.

•      At the prompt, type:  gcc lab1.c   To compile the program.

•      At the prompt, type:  a.out          To run the program.

•      After the program run is complete, type: exit     To leave the session.

NOTE:  If you forget to type exit to leave script, your script file will be empty!!!

STEP 7:  Move your files to be accessible to your browser.

Go to Power Point File 1-Unix Start, slide #6 for solutions to this situation.

STEP 8:  Turn in your work.

Go to Canvas and turn in two files:

1.      lab1.c  …the code file

2.      StudentName_lab1.txt          …the script file

STEP 9:  LOG OFF EVERYTHING.

Type “exit” when you are ready to leave athena.

Close as much as necessary for safety, depending on your location.

More products