0% found this document useful (0 votes)
71 views6 pages

Object Oriented Programming Lab Report#02 Class and Section

This document contains a lab report on object oriented programming with 3 questions - the first asks to input and print integers from an array, the second asks to find the sum of integers in an array, and the third asks to write a function to find the largest and smallest element in an array. It also lists the group members, date submitted, and includes the code for each question.

Uploaded by

Muzzamil Hussain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views6 pages

Object Oriented Programming Lab Report#02 Class and Section

This document contains a lab report on object oriented programming with 3 questions - the first asks to input and print integers from an array, the second asks to find the sum of integers in an array, and the third asks to write a function to find the largest and smallest element in an array. It also lists the group members, date submitted, and includes the code for each question.

Uploaded by

Muzzamil Hussain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

OBJECT ORIENTED PROGRAMMING

LAB REPORT#02

Class and Section:


B.Sc.(SE) PEC-Batch-02

Group Members: Roll No’s:


Muzzamil Hussain UET19F-BSc-SE-41
Ibtsam Haider UET19F-BSc-SE-05
Muhammad Usman Shafique UET19F-BSc-SE-36
Rana Muhammad Abubakar UET19F-BSc-SE-07

Submitted to: Ms.Fasiha Imtiaz

DATE: 07-10-2020
Question 1: Take 10 integer inputs from user and store them
in an array and print them
on screen.

#include <iostream>
using namespace std;
int main()
{
int arr[10];
int temp;

cout<<"Enter 10 values: \n";


for (int z = 0; z < 10 ; z++)

{
cin >> arr[z];
}

cout<<"The entered integers are: \n";


for (int z = 0; z < 10; z++)

{
cout<<arr[z]<<"\n";
}

system ("pause");

return 0;

}
Question 2: Write down a program to input 10 numbers in
array and to find their sum?

#include <iostream>
using namespace std;
int main()
{
int arr[10];
int sum=0;

cout<<"Enter 10 values: \n";


for (int z = 0; z < 10 ; z++)
{

cin >> arr[z];


sum+=arr[z];
}

cout<<"The sum of entered integers is = "<<sum<<endl;

system ("pause");
return 0;
}

Question 3: Write function which will return smallest largest


element from an array.

#include <iostream>
using namespace std;

int FindMax(int a[],int n)


{
int i, max;
max = a[0];

for(i=1;i<n;i++)
{
if(a[i]>max)
max =a[i];
}
return max;
}
int FindMin(int a[],int n)
{
int i, min;
min = a[0];
for(i=1;i<n;i++)

{
if(a[i]<min)
min =a[i];
}

return min;
}

int main()
{
int i, array[50], size, max, min;

cout<<"Input number of elements in array\n";


cin>>size;

cout<<"Enter "<< size << " integers\n";


for(i=0;i<size;i++)
cin>>array[i];

max = FindMax(array,size);
min = FindMin(array,size);

cout<<"Largest element in the array is:" << max << "\n";


cout<<"Smallest element in the array is:" << min << "\n";

return 0;
}

You might also like