Lab #1 – Hello World Solution

$30.00

Description

Goals:

  • Log on to CSE Grid
  • Use of putty and winscp
  • Linux commands: mkdir, cd, nano, g++

Development Environment: csegrid (Centos), g++

Deliverables: This page with 3 screenshots, and the name of your lab partner.

Part I – (15 pts)

  • Introduce yourself to the person sitting next to you. Write down their name below and one interesting fact about them. Today this person is your lab partner. Every lab you are required to have a lab partner so choose your seats next to the person you want to work with.

Matt Hanford

Matt just moved here from Portland.

  • Put your name below this statement: I understand that I have to attend every lab in order to get full credit for each lab.

Jake Billings

  • It is important that you follow every step. Either print this lab out or view it from the screen, but you are going to want to make sure you go through every line in order. If you have questions, first ask your lab partner, then ask your instructor.
  • From the windows computer, log in. This is the login that is usually something like your lastname and first initial
  • Once the Windows 10 desktop comes up, click on the putty icon (or type in putty at the search box on the bottom left.
  • In the Host Name type csegrid.ucdenver.pvt and click the Open Button

  • Log in as: (Use the same login you used to login to the Windows 10)

  • At the $ (we call this a prompt), type the following…pay attention to upper or lower case, as it matters!: Type the <enter> key after each line
  • ls -al (That’s an el. It stands for list)
  • mkdir lab01 (this says make a directory/folder called lab01)
  • ls -al (verify that you now have a new directory)
  • cd lab01 (change directory to lab01)
  • pwd (print working directory)
  • cd .. (change directory one level up)
  • Hit the up arrow to get your previous commands. Stop when you get to pwd, then hit enter
  • ls -al
  • cd lab01

  • Your output should be similar. If you get lost, and don’t know where you are, type pwd. If you want to see if there are any files in that directory type ls -al.
  • Note in the diagram above, if it starts with a d it is a directory (a folder), so you can change directory into that folder.
  • Now you are going to open the editor
  • nano lab01.cpp
  • Type the code below exactly, except replace AAAA with your name and BBBB with your instructors name
  • Note that there is a semi-colon after 3 statements. There is no semi-colon after the #include statement. And those are curly brackets { }, not parenthesis or square brackets. Use the Tab key before the cout statements.

 

  • Now you want to hit Ctrl + X, to Exit and say yes to save.
  • See if that file is there. At the $
  • ls -al
  • Now we are going to compile the program. At the $
  • g++ -o lab01 lab01.cpp
  • This says run the g++ compiler. The output file (that’s an Oh, not a zero) will be called lab01 and the file we are compiling is lab01.cpp
  • To run the output you must put a ./ before it. At the $ type
  • ./lab01
  • If you did all of this correctly, you should come up with something like the output below. If you got errors, go back into the file with nano lab01.cpp and fix the errors.

  • Take a screen shot of the output. In Windows, you can either click on the window and type the Alt Key + PrtSc key. Or in the search box in the bottom left you can type in Snipping Tool, then new and draw the box around what you want to copy. Paste that below:

Part II – 15 pts

  • Now lets go to your top directory, then using the statements above navigate back to lab01 and edit the file. Add the additional statements, the exit out. Once again, compile.
  • cd (changes directory to your top directory)
  • Note the comma between x=2 and y=3 and result, and the semi colon after result. Note that if you want a space in printed output like the last line, you need to put a space before the quotes”
  • Compile this with
  • g++ -o lab01a lab01.cpp
  • Now run it with
  • ./lab01a
  • Take a screenshot of the output below

 

  • Now you should move your lab01.cpp file from the csegrid to your desktop. From your desktop, click on WinSCP

  • Then you will get a screen that allows you to move files between systems with drag and drop

Now save this lab document with the screenshots and the two questions answered at the top. Hand it in via Canvas. You do not need to hand in the .cpp file for this lab.

From your home computer of laptop (off-campus only). On campus log on to the UCDenver Wireless, with your UCDenver credentials. Then skip the cisco any connect.

For Windows computers

For Mac Users