Senior Six Exam of C++
Senior Six Exam of C++
Senior Six Exam of C++
LEVEL: SENIOR 6
TERM: 1st
TIME: 3HOURS
_____________________________________________________________________________
INSTRUCTIONS:
What are the main advantages of high level language over low level language?
1. Complete the sentence below
The variables declared inside a class are called……….while functions declared
inside a class are called…….
2. a.What is an object in OOP?
b.give and explain characteristics of object
9. Write the program to enter the value of N and then calculate and display N!
11. Using a do…while loop write a program to calculate and display the sum of
numbers from 1 to 10.
12. Briefly, Give a comparison between Object Oriented Programming ( OOP) and
Procedure Oriented Programming(POP) by considering their features.(give at least five
features for each)
13. Write a C++ program to accept any number and display its multiplication table.
The sample output is like this:
17. Using a class called beta, write a C++ program which receives ten integer values of
an array and display them. (Two member functions are used, get_data( ) for inputting
the array’s elements and display_data( ) to outputting the entered values).
MARKING GUIDE FOR C++ SENIOR SIX TERM 1 2014
b. characteristics of an object
pass by value
pass by address
pass by reference
8. a. data abstraction is the process of hiding unwanted details from the user.
b. A scope resolution operator (::), can be used to define the member functions
of a class outside the class.
9. #include<iostream.h>
main()
{
Long int N, fact=1;
}while(i<=10);
#include<iostream.h>
main()
{
int i,n,result;
cout<<enter a number\n”;
cin>>n;
cout<<”MULTIPLICATION TABLE OF”<<n<<”IS”<<endl;
for(i=1;i<13;i++)
{
result=n*i;
cout<<n<<”*”<<i<<”=”<<result<<endl;
}
}
14.
#include<iostream.h>
void age_of_person(int age);
main()
{
int a;
cout<<"give the age of a person\n";
cin>>a;
age_of_person(a);
}
void age_of_person(int age)
{
if(age<=18)
cout<<"you are young";
else
cout<<"you are adult";
}
15. #include<iostream.h>
int main( )
{
int i, n;
cout<<"Enter an integer number:";
cin>>n;
cout<<"ten next numbers are\n";
for(i=n+1;i<=n+10;i++)
{
cout<<i<<endl;
}
return 0;
}
16.
#include<iostream.h>
class student
{
char name[10];
int rollno,marks[5],sum,avg;
public:
void assign()
{
cout<<"enter name of the student";
cin>>name;
cout<<"enter rollno";
cin>>rollno;
cout<<"enter marks of five subjects";
for(inti=0;i<5;i++)
{
cin>>marks[i];
}
sum=avg=0;
for(int j=0;j<5;j++)
{
sum=sum+marks[j];
}
avg=sum/5;
cout<<"Average marks is"<<avg;
cout<<endl;
if(avg>=90)
{
cout<<"stream is Computer"<<endl;
}
else
{
if(avg>=80 &&avg<=89)
{
cout<<"stream is Electronics";
}
if(avg>=75 &&avg<=79)
{
cout<<"stream is Mechanical";
}
if(avg>=70 &&avg<=74)
{
cout<<"stream is Electrical";
}
}
}
};
void main()
{
student s1;
s1.assign();
}
17. #include<iostream.h>
class beta
{
int i, t[10];
public:
void get_data(void)
{
cout<<”Enter ten numbers of the array:\n”;
for(i=0;i<=9;i++)
{
cin>>t[i];
}
}
void display_data(void)
{
cout<<”Entered numbers:\n”;
for(i=0;i<=9;i++)
{
cout<<t[i]<<”\t”;
}
}
};
int main()
{
beta b;
b.get_data();
b.display_data();
return 0;
}