You are on page 1of 9

LAB 03 Evaluation

Object Oriented Programming

Name: Muhammad Qasim Malik SAP I’d: 24374

1st CODE:
#include <iostream>

using namespace std;

int main()

int i;

int a[10]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

for (i=0; i<=9; i++){

cout<< a[i]<<endl;

return 0;

}
LAB 03 Evaluation

2nd CODE:
#include <iostream>

using namespace std;

int main()

int i;

int a[5];

for (i=0; i<=4; i++){

cout<<"Please enter value in the element "<<i<<endl;

cin>>a[i];

cout<<endl<<endl;

cout<<"****Output on the screen*******"<<endl;

for(i=0; i<=4; i++)

cout<<a[i]<<endl;

return 0;

}
LAB 03 Evaluation
LAB 03 Evaluation

3rd CODE:
#include <iostream>

using namespace std;

int main()

int a[5];

int i=0;

while(i<=4)

cout<<"Please enter value in the element "<<i<<endl;

cin>>a[i];

i++;

cout<<endl<<endl;

cout<<"****Output on the screen*******"<<endl;

i=0;

while(i<=4)

cout<<a[i]<<endl;

i++;

return 0;

}
LAB 03 Evaluation
LAB 03 Evaluation

4th CODE:
#include <iostream>

using namespace std;

int main()

int i, sum;

float avg;

int a[5];

sum=0;

for (i=0; i<=4; i++){

cout<<"Please enter value in the element "<<i<<endl;

cin>>a[i];

sum=sum+a[i];

cout<<endl<<endl;

cout<<"****Output on the screen*******"<<endl;

for(i=0; i<=4; i++)

cout<<a[i]<<endl;

avg=sum/5;

cout<<endl;

cout<< "Sum of the all elements of array = "<<sum<<endl;

cout<< "Average of the elements of array = "<<avg<<endl;

return 0;
LAB 03 Evaluation

}
LAB 03 Evaluation

5th CODE:
#include <iostream>

using namespace std;

int main()

int i, max;

int a[5];

for (i=0; i<=4; i++){

cout<<"Please enter value in the element "<<i<<endl;

cin>>a[i];

cout<<endl;

max=a[0];

cout<<"****Output on the screen*******"<<endl;

for(i=0; i<=4; i++)

if (max<a[i])

max=a[i];

cout<< "Maximum value of the array = "<<max<<endl;

return 0;

}
LAB 03 Evaluation

You might also like