0% found this document useful (0 votes)
32 views

Question 1. Write The

This document contains 34 questions related to C++ programming. The questions cover topics such as arrays, inheritance, image display, pointers, data structures, file handling, and object oriented programming concepts.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Question 1. Write The

This document contains 34 questions related to C++ programming. The questions cover topics such as arrays, inheritance, image display, pointers, data structures, file handling, and object oriented programming concepts.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Question 1.

write the
syntax to create a two
dimensional array
dynamically........?

Question 2. class Toy


{
....
}

class SoftToy: public Toy


{
....
}
class ElecToy : public Toy
{
..
}

Qn: What type of inheritance is this?

Question 3. how to display image(jpeg or gif) in c++?

Question 4. Give the output of the following program:


void main()
{
int x [] = { 10, 20, 30, 40, 50}:
int *p, **q, *t;
p = x;
t = x + 1;
q = &t;
cout << *p << “,” << **q << “,” << *t++;
}

Question 5. 20,30,+,50,40,-,*

Answer:
500
Question 6. Define the term Data Abstraction in the context of Object
Oriented Programming. Give a suitable example using a C++ code to
illustrate the same.

Question 7. What do you mean by aggregation?Give an example,

Answer:
When class contains objevts of other class types as a member.

Question 8. Write a c++ program to print prime no.s from 1 to 100 .

Question 9. How many bytes of the object of class if the inheritance is


hierarchical and multiple inheritance?

Question 10. What do you understand by the terms Cookies and Firewall ?

Answer:
Cookies: A small piece of information that a server sends to a client When
you visit a Web site with cookie capabilities, its server sends certain
information about you to your browser, which is stored on your hard drive
as a text file. At some later time (such as returning to the site the next
day), the server retrieves the cookie. It’s a way toi the server to remember
things about you.

Firewall: Any of a number of security schemes (hardware/software) that


prevent unauthorized users from gaining access to a computer network or
that monitor transfers of information to and from the network.

Question 11. What is the difference between XML and HTML ? Write two
differences.

Answer:
eXtensible Markup Language: It contains user defined tags
Hyper Text Markup Language: It contains predefined tags

Question 12. Expand the following terminologies :

(i) HTML
(ii) GSM

Answer:
Hyper Text Markup Language
Global System for Mobile communication

Question 13. What do you understand by the terms Candidate Key and
Cardinality of a relation in relational database ?

Answer:
Candidate Key: The attribute (Column) or set of attributes (Columns) which
can identify a tuple/row uniquely are known as Candidate Key(s).
OR
Candidate Key: The attribute (Column) or set of attributes (Columns),
which are capable of acting as candidate for primary key.

Cardinality of a relation: Number of rows in a table form cardinality of a


relation.

Question 14. Write a function in C++ to count and display the number of
lines not starting with alphabet ‘A’ present in a text file ‘STORY.TXT”.

Example :
If the file “STORY.TXT” contains the following lines,
The rose is red.
A girl is playing there.
There is a playground.
An aeroplane is in the sky.
Numbers are not allowed in the password.

The function should display the output as 3

Question 15. Evaluate the following postfix notation of expression :


20 10 + 5 2 * – 10 /

Answer:
Evaluate : 20 10 + 5 2 * – 10 /

Answer is ((20+10)-(5*2))/10=2.
So, the value for the postfix expn. 20 10 + 5 2 * – 10 / is 2.

Question 16. Write a function in C++ to print the sum of all the values
which are either divisible by 3 or are divisible by 5 present in a two
dimensional array passed as the argument to the function.

Question 17. Write a function in C++ to perform a DELETE operation in a


dynamically allocated queue considering the following description :

struct Node
{
float U,V;
Node *Link;
};

class QUEUE
{
Node *Rear,*Front;
public:
QUEUE(){Rear=NULL;Front=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};

Question 18. An array Arr[35][15] is stored in the memory along the row
with each of its element occupying 4 bytes. Find out the base address and
the address of an element Arr[20][5], if the location Arr[2][2] is stored at
the address 3000.

Answer:
4092

Question 19. Write a function in C++ which accepts an integer array and
its size as arguments/parameters and exchanges the values of first half
side elements with the second half side elements of the array.

Example :
If an array of eight elements has initial content as
8, 10, 1, 3, 17, 90, 13, 60
The function should rearrange the array as
17, 90, 13, 60, 8, 10, 1, 3
Question 20. Define the term Data Encapsulation in the context of Object
Oriented Programming.
Give a suitable example using a C++ code to illustrate the same.

Answer:
(i) stdio.h
(ii) ctype.h

Question 21. Name the header files to which the following belong :
(i) puts ( )
(ii) isalnum ( )

Answer:
Answer :

(i) stdio.h
(ii) ctype.h

Question 22. Differentiate between a default constructor and copy


constructor, giving suitable
examples of each.

Answer:
Default Constructor: It is type of constructor, which does not have any
parameter.

OR

Default Constructor: It is the pre-defined constructor.

Copy Constructor: It is an overloaded constructor in which object of the


same class is passed as parameter.

OR

Copy Constructor: It is a constructor, which is used to copy content of one


object to another of the same class.

class STUDENT
{
int Rno;
char Name[20];
public:
STUDENT(); //Default Constructor
STUDENT(STUDENT &S); //Copy Constructor
:
:
};
Question 23. Write two application of Cyber Law

Question 24. Expand the following terminologies :


(i) TCP/IP
(ii) XML
(iii) CDMA
(iv) WLL

Answer:
TCP/IP:-Transmission Control Protocol/Internet Protocol
XML:-eXtensile Markup Language
CDMA:-Code Division Multiple Access
WLL:-Wireless in Local Loop

Question 25. What is the difference between Message Switching technique


and Packet Switching
technique?

Question 26. What do you understand by the terms Primary Key and
Degree of a relation in relational database?

Question 27. Write a function in C++ to count and display the number of
lines starting with
alphabet ‘A’ present in a text file “LINES.TXT”.

Example:
If the file “LINES.TXT” contains the following lines,
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets and numbers are allowed in the password.

The function should display the output as 3

Question 28. Evaluate the following postfix notation of expression:

10 20 + 25 15 - * 30 /
Answer:
i think it as

::

30 *10/30
300/30= 10

Question 29. Write a function in C++ to print the sum of all the values
which are either divisible by 2 or are divisible by 3 present in a two-
dimensional array passed as the argument to the function.

Question 30. An array Arr[15][35] is stored in the memory along the


column with each of its
elements occupying 8 bytes. Find out the base address and the address of
an
element Arr[2][5], if the location Arr[5][10] is stored at the address 4000.

Answer:
ans::3376

Question 31. Write a function in C++ which accepts an integer array and
its size as
arguments/parameters and exchanges the values of first half side elements
with the second half side elements of the array.

Example:
If an array of eight elements has initial content as
2,4,1,6,7,9,23,10
The function should rearrange the array as
7,9,23,10,2,4,1,6

Question 32. Define a class TravelPlan in C++ with the following


descriptions :

Private Members:

PlanCode of type long


Place of type character array (string)
Number_of_travellers of type integer
Number_of_buses of type integer

Public Members:
A constructor to assign initial values of Plan Code as 1001, Place as “Agra”,
Number_of_travellers as 5, Number_of_buses as 1
A function NewPlan( ) which allows user to enter PlanCode, Place and
Number_of_travellers. Also, assign the value of Number_of_buses as per
the
following conditions :

Number_of_travellers Number_of_buses
Less than 20 1
Equal to or more than 20 and less than 40 2
Equal to 40 or more than 40 3

A function ShowPlan( ) to display the content of all the data members on


screen.

Question 33. Define the term Data Hiding in the context of Object
Oriented Programming. Give a
suitable example using a C++ code to illustrate the same.

Question 34. (a) Differentiate between a Call by Value and Call by


Reference, giving suitable examples of each.

(b) Name the header files to which the following belong:


(i) abs( )
(ii) strcmp( )

Answer:
Answer (a)

Call by value :

The formal parameter makes a copy of actual parameter. It does not make
the changes in actual parameter if the changes are done in formal
parameters.

Call by reference :
The formal parameter is an alias of actual parameter. The changes made in
the formal parameter are reflected in actual parameter. It is preceded by &.

void Calculate(int A,int &B)//A is call by value, B is call by reference


{
A++;
B+=A;
}

You might also like