MCIS 6204 - Data Structure & Algorithms (Labs) - Day1
MCIS 6204 - Data Structure & Algorithms (Labs) - Day1
MCIS 6204 - Data Structure & Algorithms (Labs) - Day1
Jongyeop Kim
LAB #1:
A. Environmental Setup and Basic Debugging
B. Add Simple Functionality to a program
Lab #1.A
The purpose of this Lab #1.A is to get you interacting with C++ with Eclipse, so that you
can start to see and fix the kind of simple errors that crop up all the time when
programming.
In Lab #1.A you will type in a simple program and make various changes to it to observe
how it behaves. As you to the Lab # 1.A you make predictions about what will happen, and
will record what actually happens as you make small changes to the code. Your answers
will be recorded in a text file and turn it in to your Black board. You will be able to
complete your own machine after setup development environment.
Lab #1.B
In Lab#1.B, you will start to add simple functionality to a program. It will also allow you
to start seeing the differences between integer and floating point types in C++. The
program asks the user to type in a few values from the keyboard, and then perform various
math functions with those values, and prints out the results.
___________________________________________________________________________
Directions
1. Run your Eclipse
2. Lab1A
2.1 Create Lab1A.cpp
Type in the following program. Also, change the top print statement to print your name,
section name and ID number. Then compile and run the program.
// C++ Lab1A
// <Your Name>
//<Section Name>
// <Your Student ID>
#include <iostream>
using namespace std;
int main()
{
//Declaring Variables//
int iX, iY;
Page
1 of 7
2 of 7
f. Your Prediction:
Run results:
3. Lab1B
3.1 Create Lab1B.cpp
Page
3 of 7
Type in or copy the following program. Also, change the top print statement to print your
name and ID number. Then compile and run the program.
// <Your Name>
//<Your Section Name>
// <Your Student ID>
//C++ Lab1B
#include <iostream>
using namespace std;
int main( )
{
int iX = 0;
float fY = 0;
string title;
// Declare integer variable iA, iB and
// float variables fA, fB here.
// Intialize all variables with zero.
// [Add Code Here]
// Prompt user for input
cout << "Enter two integer numbers : ";
// Read user int input and store value into variable iA
cin >> iA;
// Read in the second int value that the user
// enters and store it in iB
// Similar to the statement above
// [Add Code Here]
// Prompt the user to provide a floating value
// Similar to statements above
// [Add Code Here]
// Read user floating input and store value into variable fA
cin >> fA;
// Prompt the user to provide a second double value
// Similar to statements above
// [Add Code Here]
// Read in the second floating value that the user
Page
4 of 7
Page
5 of 7
6 of 7
fA % fB = 3.3
3.4 Hand in the program
Handin two files to the Black board
: Your source code and execution results
Lab1B.cpp, Answer(Lab1B).txt
Page
7 of 7