Lab Journal: Computer Programming (2+1 Credit Hours)
Lab Journal: Computer Programming (2+1 Credit Hours)
CSL-113
LAB JOURNAL
Fall/Spring: Spring
Year: 2022
Table of Contents
No. TASKS SIGNATURE
Lab 8 Functions – I
Lab 9 Functions - II
Lab 13 Pointers
Task 1:
Install Visual C++ and attach proper screenshots to Lab File.
Solution:
Installed successfully:
Task 2:
Write a C++ program to store statement record such as (Name,
Age, Grade and CGPA).
Solution:
#include <iostream>
int main()
{
cout << "Name:" << "Dawood Shahzad" << endl;
cout << "Age:" << "30" << endl;
cout << "CGPA:" << "3.8" << endl;
cout << "Grade:" << "A" << endl;
system("pause");
return 0;
}
Task 3:
Write a C++ program to read student’s three grade, calculator
the average of the grade, and then display the average grade.
Solution:
#include <iostream>
using namespace std;
int main() {
int English=5;
int Physics=5;
int Maths=5;
int Average;
Average=English+Physics+Maths;//sum the marks of grades
Average=Average/3;//now divide them by their 3
cout<<"Average is:"<<Average<<endl;
cout<<"Grade 1 numbers are 5"<<endl;//english
cout<<"Grade 2 numbers are 5"<<endl;//physics
cout<<"Grade 3 numbers are 5"<<endl;//maths
system("pause");
return 0;
}
Task 4:
Write program that reads the height, length , and width of the
rectangular box , Calculates and displays the volume.
Note: Volume = lwh.
Solution:
#include <iostream>
using namespace std;
int main() {
int HEIGHT=4;//HEIGHT GIVEN HERE
int LENGTH=8;//LENGTH GIVEN HERE
int WIDTH=6;//WIDTH GIVEN HERE
int volume;
volume = HEIGHT*LENGTH*WIDTH;//USING FORMULA