Beruflich Dokumente
Kultur Dokumente
CS-113
Lab Journal
Objectives:
Tools Used:
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;
}