Date: 1/4/2013
Instructor: Abdulaziz(network security PhD candidate)
Time: two hours
Lab teaching method: writing all lab programs correctly
in your group with cooperation with subject Instructor.
Important note:
1.
2.
3.
////////////////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
int main()
{
// Declare the members of the array
int numbers[] = {8, 25, 36, 44, 52, 60, 75, 89};
int find,t;
int i, m = 8;
cout << "Enter a number to search: ";
cin >> find;
for (i = 0; (i < m) && (numbers[i] != find); ++i)
continue;
//Find whether the number typed is a member of the
array
if (i == m)
cout << find << " is not in the list" << endl;
else
cout << find << " is the " << i + 1
<< "th element in the list" << endl;
cin>>t;
return 0;
}
//////////////////////////////////////
#include <iostream>
using namespace std;
#include <iomanip>
using std::setw;
int main ()
{
int n[ 10 ]; // n is an array of 10 integers
int t;
// initialize elements of array n to 0
for ( int i = 0; i < 10; i++ )
{
n[ i ] = i + 100; // set element at location i to
i + 100
}
cout << "Element" << setw( 13 ) << "Value" << endl;
// output each array element's value
for ( int j = 0; j < 10; j++ )
{
cout << setw( 7 )<< j << setw( 13 ) << n[ j ] <<
endl;
}
cin>>t;
return 0;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////////////
#include <iostream>
using namespace std;
int main ()
{
int var1,t;
char var2[10];
cout << "Address of var1 variable: ";
cout << &var1 << endl;
return result;
}
Exercise1:
1. Write a program which send array on five numbers,
than return the biggest one.