Sie sind auf Seite 1von 7

Computer Programming Lab# 10

CS-113

Lab Journal

Student Name : Qazi Osama Jamil


Enrolment No. : 01-134171-063
BSCS-1B

Department of Computer Science


BAHRIA UNIVERSITY, ISLAMABAD
Lab #09

Objectives:

1. To write programs of given exercise.

Tools Used:

1. Visual Studio 2010

Submission Date: 04-05-2017

Evaluation: Signatures of Lab Engineer:


Task 1;
//Task # 1 : Declare an array of 5 doubles and assign them any values. Assign a value
of 6.5 to the 3rd element of the array declared above. Display the first value of the
array in question 1. Using a for loop display the values of the array in question 1.
#include<iostream>
using namespace std;
int main()
{
double a[5]={
a[0]=2,
a[1]=4,
a[2]=6,
a[3]=6.5,
a[4]=8,
};
cout<<"First value is"<<a[0]<<endl;
for(int i=0;i<5;i++)
{
cout<<"value at index"<<i<<":"<<a[i]<<endl;

system("pause");
return 0;

Task # 2
#include<iostream>
using namespace std;
int main()
{
int a[10];
for(int i=0;i<10;i++)
{
cout<<"enter value"<<endl;
cin>>a[i];

}
int max=0,min=a[0];
for(int j=0;j<10;j++)
{
if (a[j]>max)
{
max=a[j];
}
}
for(int k=0;k<10;k++)
{
if(a[0]>=a[k])
{
min=a[k];
}
}
cout<<"Maximum number is "<<max<<endl;
cout<<"Minimum number is"<<min<<endl;
system("pause");
return 0;

//Task # 3.
#include<iostream>
using namespace std;
int main()
{
int a[5];
int v[5];
int d[5];
cout<<"Enter value for first array"<<endl;
for(int i=0;i<5;i++)
{
cout<<"enter values"<<endl;
cin>>a[i];
}
cout<<"Enter value for second array"<<endl;
for(int k=0;k<5;k++)
{
cout<<"enter values"<<endl;
cin>>v[k];
}
for(int g=0;g<5;g++)
{
d[g]=a[g]+v[g];
}
for(int z=0;z<5;z++)
{
cout<<"d["<<z<<"] = "<<d[z]<<endl;
cout<<endl;
}

system("pause");
return 0;

}
Task 4:
#include<iostream>
using namespace std;
void getinput(int a[]);
int main()
{

int a[5];
getinput(a);
cout<<"Values are";
for(int g=0;g<5;g++)
{
cout<<a[g]<<" ";
}system("pause");
return 0;

}
void getinput(int a[5])
{
for(int k=0;k<5;k++)
{
cout<<"enter value"<<endl;
cin>>a[k];
}

}
Task 5:
//Task # 1 : Declare an array of 5 doubles and assign them any values. Assign a value
of 6.5 to the 3rd element of the array declared above. Display the first value of the
array in question 1. Using a for loop display the values of the array in question 1.
#include<iostream>
using namespace std;
int Arrayfiller(int a[]);
int main()
{

int i,q;
int a[10];
cout<<"Enter 10 Values of Array "<<endl;
for(i=0;i<10;i++){
cout<<"Enter value : "<<endl;
cin>>q;
a[i]=q;
}
cout<<" Count of Even is "<<Arrayfiller(a)<<endl;

system("pause");
return 0;

}
int Arrayfiller(int a[10])
{
int i;
int count=0;
for(i=0;i<10;i++)
{
if(a[i]%2==0)
count++;
}
return count;
}

Das könnte Ihnen auch gefallen