CSCI 261 - Programming Concepts (C++)

Fall 2017 - Lab 1A

Quick Links: Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |
This lab is due by Tuesday, August 29, 2017 11:59 PM .

The IDE



This lab teaches you how to create a C++ Cloud9 program from scratch. Cloud9 is an Integrated Development Environment (IDE) designated to facilitate the development of software solutions. Cloud9 includes an editor, a compiler, a linker, a debugger, and many other additional tools to help programmers write high quality software.

Depending on its complexity, a software project will have many different files associated with it, such as the source code (instructions written using a programming language), header files (mostly definitions), resource files (images, sounds), data files, and configuration files. Most IDEs, including Cloud9, require programmers to organize all of these files into an entity called a project. More complex software may be built from many inter-related projects that are organized into a solution (a container for projects). But, in our course this semester, we will only develop single-project solutions.


Creating a C++ Empty Project



Before you begin, delete the files that Cloud9 gives you by default. You can highlight the four files, right click, and select "Delete" from the pop-up menu.

Now you may proceed to create your first C++ Cloud9 project. How exciting! On the left hand window, right click on the name of your workspace that you created in Lab0. Select "New Folder" and name it "A1" (we'll find out why in Lab1B). Now add another new folder to A1 and call it "Lab1A". Wonderful! Read the next paragraph about file naming before moving on.

Let us now provide you with a few important notes about names for projects, solutions, and development files in general. Avoid using spaces or any special characters when naming your project. We highly recommend using short names (less than 10 characters). If you want to use more than one word, use underscores to connect the words or appropriate use of upper/lower case (e.g., MyGame). Also, make sure your chosen name has a meaning so you can remember what the project is later (e.g., Lab1A).


Adding a New C++ Source Code File



Your task is to create a source file named ''main.cpp''. Right click the Lab1A folder and choose "New File" from the pop-up menu. The same rules we discussed for a project's name apply for a source code's name as well. In most cases, we will name the first source code file of a project simply ''main.cpp''.


Writing your Code



After you have successfully added a new source code file, double click the file to open it with a text editor. You can now start typing code. Sweet! Since this is a programming class, not a typing class, enter the code between the following lines with cut/paste:

/* CSCI 261 Lab 1A: XXXX (_GIVE_BRIEF_DESCRIPTION_HERE_)
 *
 * Author: XXXX (_INSERT_YOUR_NAME_HERE_)
 *
 * More complete description here...
 */

// The include section adds extra definitions from the C++ standard library.
#include <iostream> // For cin, cout, etc.

// We will (most of the time) use the standard library namespace in our programs.
using namespace std;

// Define any constants or global variables below this comment.

// Must have a function named "main", which is the starting point of a C++ program.
int main() {

  /******** INSERT YOUR CODE BELOW HERE ********/

  cout << "Hello world!" << endl; // print Hello world! to the screen

  /******** INSERT YOUR CODE ABOVE HERE ********/

  return 0; // signals the operating system that our program ended OK.
}
	

Next, edit all places where XXXX appears in your main.cpp file with the appropriate information. When you are done, you can save main.cpp by typing Ctrl+s. Note the asterisk next to the filename in the tab (which means unsaved lines) disappears once the save completes.


Running your Code



The easiest way to compile and execute your project is to click the "Run" button at the top menu bar. A new tab should appear below with the following output:

Running /home/ubuntu/workspace/A1/Lab1A/main.cpp
Hello world!

Congratulations! You've written and run your very first program! The first line is Cloud9 telling you what program it is running. The second line is the actual output from your program. How cool!


The Iterative Process



Now that your program is running, we are going to add two more output statements following the "Hello world!" line. Add a second cout statement that prints

How are you?

Run your program again to verify you are seeing the new output on the screen. Finally, add a third line to print (note the spaces)

   (I'm fine).

Run your program again. When you are complete, your program should output

Hello world!
How are you?
   (I'm fine).

You just went through a short iterative process, or as programmer's say an incremental build. Once you knew you had your program running properly, you made a small change to the program and reran the program to verify the change was correct. Once again, a small change was introduced to the code and the program was run to verify the proper output. You should become very familiar with this process as it will make future projects go smoother if you make small changes at a time.

This lab taught you how to create a C++ Cloud9 project from scratch and output statements to the screen. You need to know how to create an empty project from scratch. Thus, feel free to create a second new empty project for grins (i.e., do this lab a second time when you start Lab1B).


Lab Submission



You will submit your solution to this lab with your first official homework assignment (Assignment 1). Detailed instructions for doing this are posted in Assignment 1.


Optional Material: Details on the Cloud9 Interface



The default interface can be described in five sections: the menus, left pane, Code Window, Output Window, and right pane.

The menus have the same functionality of most Microsoft Windows programs (e.g., Open File); there are, however, menu items that are specific to programming.

The left pane has several different views. You will almost always use the Workspace tab which is similar to Windows Explorer. All of the code files associated with your projects (i.e., program) will appear here.

The Code Window is where you will type/edit your C++ programs. It works similar to a text editor with the bonus of syntax coloring and segment grouping. You can have multiple code windows open - they will stack as tabs at the top of the Code Window. These tabs allow you to easily jump between multiple files when editing. You can drag a tab to open to windows side by side for easy viewing.

The Output Window keeps track of information from the compiler. When you build your program (or code), this window will list any problems that it found and give you tools to help you find and fix those problems. If there were no errors building your program, then the output from your program will appear in this window.

The right pane also has several different views. The Collaborate tab may be most helpful in class to use to chat during live coding examples. As our programs become more complex, the Outline tab will allow you to quickly jump around your code. We will discuss the Debugger later as a helpful tool to find and correct errors in our programs.


This lab is due by Tuesday, August 29, 2017 11:59 PM .
Last Updated: 08/12/17 09:14


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0