Cit 2210 Computer Programming II
Cit 2210 Computer Programming II
QUESTION ONE
1) Algorithm
2) Program
3) Syntax
# include <iostream>
using namespace std;
int main()
{
(out << “Enter The Size Of Array:”;
int size;
(in>>size;
int array [size], key, i;
//Taking Input in array
For (int j=O; j<size; j(++)
{
Cout << “Enter”<<j<< “Element:”;
Cin>>array[j];
}
//Your Entered Array is
for (int a=0; a<size; a++)
Cout<< “array [“<<a<<”]=”;
Cout<<array [a]<<end i;
}
Cout<< “Enter key To search in Array”;
Cin>>key;
For (i=0, T<size ;T++)
{
If (key ==array [i])
{
Cout << “key Found At Index Number:
“<<i<<end1;
break;
}
}
If (I !=size)
{
Cout << “KEY FOUND at index:” <<I;
}
else {
Cout<< “KEY NOT FOUND in array”;
}
Return O;
}
1) End | (3 marks)
2) Cin >>
3) \t
h) List and explain the input and output operations in C++ (4 marks)
QUESTION TWO
1) / and %
2) = and ==
3) $$ and //
b) List down and describe the main C++ data types (4 marks)
QUESTION THREE
1) Inheritance
2) Single inheritance
3) Multiple inheritance
d) Using a suitable C++ program show how an array can be used to display
the sum and average of ten numbers entered by the user (5 marks)
QUESTION FOUR