Professional Documents
Culture Documents
Class: BEE-13D
Fall 2022
Instructor: Mehreen
Tahir
To build the triangle, start with "1" at the top, and then continue placing numbers below it in a
triangular pattern. Each number is the numbers directly above it added together. (Here I have
highlighted that 1+3 = 4)
This lab task was excluded by the instructor ( Miss Mehreen Tahir)
Activity#1
Run the following program and attach screen shot of output
Programs Output
2. Portability
The ability to port i.e. to install the software in different platform is called portability.
Highest degree of portability: ‘C++’ language offers highest degree of portability i.e.,
percentage of changes to be made to the sources code is at minimum when the software is
to be loaded in another platform. Percentages of changes to the source code are minimum.
Activity#2:
Write a complete C++ program that produces the following output:
\/
\\//
\\\///
///\\\
//\\
/\
THIS ACTIVITY WAS EXCLUDED BY INSTRUCTOR
Lab Tasks:
CODE:
#include<iostream>
using namespace std;
int main()
{
int r,A,C;
cout << "Enter the radius of circle"<<endl;
cin >> r;
A = (3.14)*(r)*(r);
C = (2)*(3.14)*(r);
cout << "The Area of circle is" <<A<<endl;
cout << "The perimeter of circle is" <<C<<endl;
system("pause");
return 0;
}
SCREENSHOT:
else{
cout << "The numbers are not equal"<<endl;
}
system("pause");
return 0;
}
SCREENSHOT:
int main() {
int i, n;
float arr[500];
SCREENSHOT:
5. Write a C++ program to count the number of occurrences of given number in a sorted
array of integers.
CODE:
#include <iostream>
using namespace std;
int frequency_count(int arr[], int num, int size){
int count = 0;
for (int i = 0; i<size; i++){
if (num == arr[i]){
count++;
}
CS 212: Object Oriented Page
Programming 11
}
return count;
}
int main(){
int arr[] = { 0, 1, 1,5,1,1,2, 2, 3, 4 };
int num =1;
int size = sizeof(arr) / sizeof(arr[0]);
cout << "Count of number of occurrences (or frequency) are: " << frequency_count(arr,
num, size);
cout << endl;
system("pause");
return 0;
}
SCREENSHOT:
6. Write a C++ program to update every array element by multiplication of next and
previous values of a given array of integers
7. Input 10 numbers and find their sum, Multiplication and average, also find prime
numbers from the entered numbers.
CODE:
#include<iostream>
using namespace std;
int main()
{
int a, b, c, A, d, e, f, g, h, i, j, S, M;
cout << "Enter the 10 numbers";
cin >> a;
cin >> b;
cin >> c;
CS 212: Object Oriented Page
Programming 12
cin >> d;
cin >> e;
cin >> f;
cin >> g;
cin >> h;
cin >> i;
cin >> j;
S = (a + b + c + d + e + f + g + h + i + j);
A = (a + b + c + d + e + f + g + h + i + j) / 10;
M = (a*b*c*d*e*f*g*h*i*j);
cout << "The average og given numbers is " << A << endl;
cout << "The Sum of the given numbers is " << S << endl;
cout << "The product of given numbers is " << M << endl;
system("pause");
return 0;
}
SCREENSHOT:
int main()
{
int a, b, c,A,d;
cout << "Enter the age of students";
cin >> a;
cin >> b;
cin >> c;
cin >> d;
A = (a + b + c + d) / 4;
cout << "The average age of students is " << A << endl;
system("pause");
return 0;
CS 212: Object Oriented Page
Programming 13
}
SCREENSHOT:
Deliverables: Complete lab manual by performing all tasks. Copy paste your code and screen
shot of console window as a solution of each task. You are required to upload the lab tasks on
LMS and the name of the task must be in this format YourFullName_reg#.