FACULTY OF ARTS AND SCIENCES
CSI205 – Programming I Lab
All Sections
Fall Term 2021-2022
Lab Work 1
Part 1 - Introduction
I. Introduction to Computer Programming I Lab (CSI205L) objectives and
requirements.
II. Explanation of lab policies and procedures, as well as lab syllabus and grading
policy. (Read and explain the syllabus in details)
III. Work on the C++ environment to show students the following steps:
1. Create a new Win32 Console Application empty project
workspace.
2. Type and save the following C++ program as “Program1.cpp”.
#include <iostream>
using namespace std;
int main( )
{
system("pause");
return 0;
}
3. Compile, link and execute the program. (explain each step)
4. Type “Return 0” instead of “return 0” and ask students to repeat
step3. Show students how to correct the compilation mistakes till
they are able to execute the program.
5. Type “int Main” instead of “int main” and ask them to repeat step
3. Show students the difference between the linking and
compilation errors.
6. Ask the students to remove “system("pause");”, and to repeat
step 3. Discuss with students the program execution results.
1
,Part 2 – Practice
1. Create a new Win32 Console Application empty project
workspace.
2. Type and save the following C++ program as “Program2.cpp”.
#include <iostream>
using namespace std;
int main( )
{
cout<<"American University of Science & Technology\n\n";
cout<<"Department Of Computer Science\n\n\n";
cout<<"CSI205L – Programming I Lab\n";
cout<<"Fall 2020/2021\n";
system("pause");
cout<<"\nWelcome to the Microsoft Visual Studio 2013 C++
programming environment";
cout<<"\n\nCSI205L First Lab Session\n";
system("pause");
system("pause");
cout<<"GOOD LUCK ALL\n";
system("pause");
return 0;
}
3. Compile, link and execute the program. Discuss with students the program
execution results.
Part 3 – Write Program:
Write a C++ program to output AUST in block letters using asterisks.
2
, Lab Work 2
Problem 1: Find the errors and correct them.
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() int main{ }
{ (
x=0; int x = 3;
cout<<x; cout<<x;
system("pause"); Return 5;
return 0; )
}
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() int Main()
{ Int x; {
x=3; float y;
cout<<x; y=5.02;
} cout<<y;
return 10
}
Problem 2: What is the output of the following programs?
#include <iostream>
using namespace std;
int main()
{
float n ;
n=2.0 ;n=n*n ;
n= n*n ;
n=n*n;
cout<<"n = "<<n<<"\n";
system("pause");
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int day, month, year ;
day=05; month=10;
3
, year = 2020;
cout<< "Day\tmonth\tyear\n";
cout<< "---\t-----\t----\n";
cout<<day<<"\t"<< month<<"\t"<< year<<endl;
system("pause");
return 0;
}
Problem 3:
Fill in the blanks with the missing C++ statements that find the average of three given
grades:
//this c++ program calculates and outputs the average:
#include <iostream>
using _____________ std;
int main()
{ int G1,G2,G3;
double Avg;
G1=75; G2=80;
G3= 90;
Avg = _________________;
cout<<"The grades are: "<<____<<____<<____<<"\n";
cout<<”the average =”<<________________________;
system(_________);
return 0;
}
Problem 4:
Type the following program then apply the below listed steps:
//this c++ program output the measurement units values
#include <iostream>
using namespace std;
int main()
{
cout<<"measurements units\n";
cout<<"------------ -----\n\n";
cout<<"1m = 100cm"<<endl;
system("pause");
return 0;
}
1. Compile, link then execute the program.
2. Type a cout statement to display "1m = 1000mm";
3. Type a cout statement to display "1m = 39.37 inches";
4. Modify the program to show the same output using only one cout statement.
4