Name:
Sec: 06/06/2006
We will be using Microsoft's Visual Studio .NET development environment for performing labs and writing programs in this course. The lab machines have a version of Visual Studio installed on them for your use for labs and programming assignments. In addition, you will be given access to our schools MSDNAA software download site so that you may obtain a free and valid copy of the software for your own use at home or on a laptop.
The first part of this lab is meant to be a simple review of the basics of writing a program in C++, creating a main function, and using iostream object to do simple program output. You will be asked to create a simple program, using the Microsoft Visual Studio .NET development environment, and save, compile and execute your program.
In the first part of this lab you will refamiliarize yourself with creating a simple C++ program, and compiling, saving, debugging and executing your program using the Visual Studio .NET software development environment. We will review some of the most basic concepts of a C++ program, such as writing a main() function and outputting a text string.
Start up the Visual Studio .NET development environment and create a new project (You can hit the “New Project” button on the Start Page, or use the file pulldown menu sequence File->New->Project). A New Project dialog will be displayed. Expand the Visual C++ projects in the Project Types on the left and select the .NET category. Among the templates on the right hand side, choose an Empty Project (.NET). Finally you need to name your project. Give your project the name Lab1. Whenever you are starting a new lab or programming assignment, your first step will be this one, to create a new empty project and give it a name.
Our project for
lab 1 will be very simple, it will consist of a single source file.
You need to add a source file to your project so that you can write
your C++ code for this lab. If you cannot see the Solution Explorer
in Visual Studio, open it up by select the menu sequence
View->Solution E
xplorer.
The solution explorer is used to manage all of the files and
resources you use to build a project, and looks something like the
picture on the right. You need to add a source file to your
project, called Lab1.cpp. To do this, right click on the “Source
Files” folder in the Solution Explorer and select Add->Add New
Item. Select the C++ (.cpp) as the file template, and name the file
Lab1.cpp. You should now see that a file called Lab1.cpp has been
added to your Lab1 project in your Source Files, and you should have
a new tab with a title of Lab1.cpp ready to type in your source code
for the project.
Lets create a simple “Hello World” program. Type in the following code in your Lab1.cpp source file:
// Name: John H. Hacker
// Assg: Lab #1
// Date: June 6, 2006
// Desc: This program demonstrates the use of a simple
// main() function, and displaying output to a
// terminal window using the C++ iostream library.
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World" << endl;
system("pause");
}
Make sure you save your file at this point. Did you remember the ; at the end of your statements? Did you use double quotes? Do you remember how to use the iostream library objects, like cout (if you are not familiar with the iostream you might want to review the first few sections of chapter #3). main() in this simple program is actually an example of a function, do you remember how to write functions. What is special about the main() function in C++.
We will now try and compile your program. To compile your program, use the build menu item to select Build->Build Solution. This causes all of the files in your project to be rebuilt and compiled together. In the Output window at the bottom of Visual Studio, you should get the following message:
Build: 1 succeeded, 0 failed, 0 skipped
If you had error messages instead, you should go back to step 3 and fix them. The process of finding and fixing errors in a program is known as debugging the program.
If your program built successfully, you should now test it by executing your program. Start your program by choosing the pulldown menu sequence Debug->Start (or push the play button next to the Debug item on your menu bar). If your program was correct and successfully runs, you should see a Dos terminal pop up and display the words “Hello World” followed on the next line by “Press any key to continue…”. If you press a key, the terminal should go away and you can go back to Visual Studio and do more work if needed.
This completes the first part of our lab. At this point you should have refamilarized yourself with how to start up the Visual Studio development environment. Also we have covered creating a simple project, adding a file to the project, and writing a simple C++ main function to display the words “Hello World”. You should also be familiar now with how to compile a program in Visual Studio and how to run the program and see its results.
This semester we will be using the new eCollege online eduction software. Our course is not an online course, however the eCollege system has other uses. For our course, the main purpose of using eCollege will be to provide you with a standard location and way of submitting your labs and programming assignments for evaluation.
In the second part of this lab you will log onto the eCollege online account that has been created for you. You will learn how to submit your programs to the eCollege system for grading.
Open up a web browser and navigate to Texas A&M-Commerce’s new online education software site. The full address of the site is:
Log onto your user account. Your User ID will be your campus wide id. For your password, you will be using your pin number (the same pin as for your MyLeo account access).
Once you are in to the eCollege system, you will need to select the CSci 152 course from My Courses. You should already be entered in as a student for this course for the summer, so you should see CSci 152 as an available couse in the system.
Once into the course, you may want to read the announcements and look at the syllabus. If you might be using the eCollege system more in the future, or want more info on how to use eCollege in general, you should run the the “Student Tutorial” listed on your home page in eCollege.
To complete this lab you need to successfully upload the Lab1.cpp hello world file that you created in part 1.1 of this lab to your eCollege account. If you used the default location when you created your Visual Studio project, the Lab1.cpp source file will be located somewhere like “My Documents\Visual Studio Projects\Lab1”. This location may vary depending on what directory you created the Lab1 project within.
Once you have found your Lab1.cpp source file, you need to upload it to your eCollege account. In your web browser, in the eCollege system, find and open the Dropbox tab near the top. In the Basket pulldown item, you should find an item called Lab 1. Select this basket and hit Go.
You should upload your source file into the Lab 1 dropbox.
You have now completed Lab 1. If your program compiles and runs correctly and you have successfully uploaded your Lab1.cpp source file to the eCollege online submission site, then you are done. At this point, you might wan to review any concepts about C++ that you might have been fuzzy about, such as using the iostreams for input/output, or writing functions, etc, from the Malik textbook. You could also start looking at our first programming assignment, which will ask you to extend your hello world program by adding a new function and writing some loops and if/then control structures.