Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Senior Six Exam of C++

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 10

INTERSCHOOL EXAM OF ----C++ PROGRAMMING --------------

LEVEL: SENIOR 6

TERM: 1st

ACADEMIC YEAR: 2014

TIME: 3HOURS

_____________________________________________________________________________

INSTRUCTIONS:

- This exam has three sections: A, B and C


- Section A: answer all the questions (55 marks)
- Section B: choose three section to answer (30 marks)
- Section C: choose one question (15 Marks)

SECTION A: ATTEMPT ALL NUMBERS/55Marks

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

4. Define the terms below:


a. Compiler
b. Debugger
5. Give and explain any 3 types of access specifiers (permission labels)?

6. List down the characteristics of constructor.


7. a.Where will you define a member function?

b.List different parameter passing techniques

8.a. what is data abstraction?

b. what is scope resolution operator?

9. Write the program to enter the value of N and then calculate and display N!

10. While purchasing certain items a discount of 10% is offered if the


quantity purchased is more than 1000.if the quantity and price per item are
input through the keyboard, write a program to calculate the total expenses.

11. Using a do…while loop write a program to calculate and display the sum of
numbers from 1 to 10.

SECTION B: ATTEMPT ANY THREE NUMBERS/30Marks

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:

14. using function called


age_of_person(),write a program to
enter the age of a person and display
”you are young”, if the age is less
than or equal to eighteen. otherwise
it will display”you are adult”.

15. Write a program which receives


an integer number and print out ten
next numbers from it, using a loop.

SECTION C: CHOOSE ONLY ONE QUESTION/15 Marks


16. Write a program in which a class has three data members: name, roll no,
marks of 5 subjects and a member function assign () to assign the streams on the
basis of table given below:

Avg. Marks Stream


90% or more Computers
80% - 89% Electronics
75% - 79% Mechanical
70% - 74% Electrical
The user must enter the student name, roll no and the marks obtained in different five
subjects. The above stream will be displayed based on the average marks in those 5
subjects.

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

SECTION A: ATTEMPT ALL NUMBERS/55Marks

1. The main advantage of high-level languages over low-level languages is that


they are easier to read, write, and maintain.
2. Data members
Member functions
3. a. objects are the basic runtime entities in an object oriented system. They may
represent a person,a place , a table,…

b. characteristics of an object

attributes: these are data characterizing an object.(variables that store


information of the state of an object)

methods: also known as member functions. they characterize the behavior of


an object.(operation or action that can be realized by an object)

4. a. A compiler is a program that reads code and produces a stand-alone


executable that the CPU can understand directly. It translates text file written
in high level language into machine language at once.
b.Debugger is a program in charge of detecting and correcting errors in
computer codes
5. Public, protected and private are three access specifiers in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived
classes.
Private data members and member functions can’t be accessed outside the
class. However there is an exception can be using friend classes.
6. Characteristics of a constructors:
 Should be declared in the public section.
 Are invoked automatically when the object is created.
 They cannot be inherited.
 Cannot refer to their addresses.
 They have the same name as the class they belong to.
7. a. inside of class declaration and outside of the class declaration

b. parameter passing techniques

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;

cout<<" enter a number\n";


cin>>N;
for(int i=N;i>1;i--)
{
fact*=i;
}
cout<<"N!="<<fact<<endl;
}
10. #include<iostream.h>
main()
{
Int qty,dis=0;
Float rate,tot;
cout<<”enter the quantity and rate”;
cin>>qty;
cin>>rate;
if(qty>1000)
{
dis=10;
}
tot=(qty*rate)-(qty*rate*dis/100);
cout<<”total expenses”<<tot;
}
11. #include<iostream.h>
int main()
{
int i, sum=0;
i=1;
cout<<"numbers from 1 to 10 are\n";
do
{
sum=sum+i;
cout<<i<<endl;
i++;

}while(i<=10);

cout<<" and their sum is equal to: "<<sum<<endl;


return 0;
}
SECTION B: ATTEMPT ANY THREE NUMBERS/ 30Marks
12.

features of OOP features of POP


Emphasis is on data rather than Emphasis is on doing
procedure things(algorithms)
Programs are divided into what we call Large programs are divided into
objects smaller programs known as functions.
Most of functions share global data
Function and data both are tied In POP(procedure oriented language)
together in a single unit. groups of instructions are written
which are executed by compiler in a
serial manner
Data is not accessible by external Data move openly around the system
functions as it is hidden from function to function
It is easy to add new data and Functions transform data from one
functions whenever required form to another
Follow bottom-up approach in Employs top-down approach in
program design program design
13.

#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;
}

SECTION C: CHOOSE ONLY ONE QUESTION/15 Marks

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;
}

You might also like