Computer Science C++ (083) Assignment Booklet Class Xii Academic Session: 2016-17
Computer Science C++ (083) Assignment Booklet Class Xii Academic Session: 2016-17
ASSIGNMENT BOOKLET
CLASS XII
6. Inheritance 15
7. Arrays 21
8. Pointers 25
9. File Handling 29
March
Object Oriented Programming
Function Overloading
April
Classes and Objects
Constructors and Destructors
Inheritance: Extending Classes
May
Arrays
Project Allocation
July
Pointers
Data File Handling
August
Linked Lists, Stacks & Queues
September
First Term Examination
Boolean Algebra
October
Concepts of Networking
Structured Query Language
November
Revision
Project and File Submission
December
Second Term Examination
Object Oriented Programming: The object oriented programming paradigm models the real
world well and overcomes the shortcomings of procedural paradigm. It views a problem in
terms of objects and thus emphasizes on both procedures as well as data. It follows a bottom up
approach in program design and emphasizes on safety and security of data.
Important Concepts in
OOPS: Data Abstraction:
It refers to the act of representing essential features without including the background details.
Example: For driving , only accelerator, clutch and brake controls need to be learnt rather than
working of engine and other details.
Data Encapsulation:
It means wrapping up data and associated functions into one single unit called class.
A class groups its members into three sections: public, private and protected, where private and
protected members remain hidden from outside world and thereby helps in implementing data
hiding.
Modularity:
The act of partitioning a complex program into simpler fragments called modules is called as
modularity.
It reduces the complexity to some degree.
It creates a number of well defined boundaries within the program.
Inheritance:
Inheritance is the process of forming a new class from an existing class or base class. The base
class is also known as parent class or super class.
Derived class is also known as a child class or sub class. Inheritance helps in reusability of code ,
thus reducing the overall size of the program.
Polymorphism:
Poly means many and morphs mean form, so polymorphism means one name multiple forms.
It is the ability for a message or data to be processed in more than one form.
C++ implements Polymorphism through Function Overloading, Operator overloading and
Virtual functions.
SHAPE
area()
RECTANGLE() TRIANGLE() CIRCLE()
Area(rectangle) Area(triangle) Area(circle)
Advantages of OOPS:
1. Reusability of code
2. Ease of comprehension.
3. Ease of fabrication and maintenance.
4. Easy redesign and extension.
Class XII Computer Science (C++) Page 4
Smart Skills Sanskriti School
Handout II –Implementing Polymorphism in C++ through Function Overloading
C++ allows you to specify more than one definition for a function name in the same scope,
which is called function overloading.
An overloaded declaration is a declaration that had been declared with the same name as a
previously declared declaration in the same scope, except that both declarations have different
arguments and obviously different definition (implementation).
When you call an overloaded function, the compiler determines the most appropriate definition
to use by comparing the argument types you used to call the function with the parameter types
specified in the definitions. The process of selecting the most appropriate overloaded function is
called overload resolution.
You can have multiple definitions for the same function name in the same scope. The definition
of the function must differ from each other by the types and/or the number of arguments in the
argument list. You can not overload function declarations that differ only by return type.
Following is the example where same function print() is being used to print different data
types:
#include <iostream.h>
void print(int i) {
cout << "Printing int: " << i << endl; }
void print(double f) {
cout << "Printing float: " << f << endl; }
void print(char* c) {
cout << "Printing character: " << c << endl; }
int main(void)
{
print(5); // Call print to print integer
print(500.263); // Call print to print float
print("Hello C++"); // Call print to print character
return 0;
}
When the above code is compiled and executed, it produces the following result:
Printing int: 5 Printing
float: 500.263
Printing character: Hello C++
The variables inside class definition are called as data members and the functions are called
member functions.
For example: Class of birds, all birds can fly and they all have wings and beaks. So here flying is
a behavior and wings and beaks are part of their characteristics. And there are many different
birds in this class with different names but they all posses this behavior and characteristics.
Similarly, class is just a blue print, which declares and defines characteristics and behavior,
namely data members and member functions respectively. And all objects of this class will share
these characteristics and behavior.
A Class is a group of similar objects that share common characteristics and relationships. It acts
as a blueprint for defining objects.
Declaration/Definition:
A class definition starts with the keyword class followed by the class name; and the class
body, enclosed by a pair of curly braces. A class definition must be followed either by a
semicolon or a list of declarations.
class class_name {
access_specifier_1: member1;
access_specifier_2: member2;
...
} object_names;
Where class_name is a valid identifier for the class, object_names is an optional list of names for
objects of this class. The body of the declaration can contain members that can either be data or
function declarations, and optionally access specifiers.
Note: the default access specifier is private.
Example: class Box {
int a;
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
Objects:
Class is mere a blueprint or a template. No storage is assigned when we define a class. Objects
are instances of class, which holds the data variables declared in class and the member functions
work on these class objects. Objects are basic run time entities in an object oriented system.
An object is an identifiable entity with some characteristics and behavior.
For example: Dogs have characteristics (name, color, breed) and behavior (barking, fetching,
wagging tail). Cars also have characteristics (number of doors, number of seats, type of engine,
fuel type, average performance) and behavior (moving forward, moving backward, turning,
changing gear, applying brakes). Identifying the characteristics and behavior for real-world
objects is a great way to begin thinking in terms of object-oriented programming. These real-
world observations all translate into the world of object-oriented programming.
Software objects are conceptually similar to real-world objects: they too consist of state and
related behavior. An object stores its state in fields (variables in some programming languages)
and exposes its behavior through functions.
In C++, a class variable is known as an object. The declaration of an object is similar to that of
a variable of any data type. The members of a class are accessed or referenced using object of
a class.
Inline Functions
Inline functions definition starts with keyword inline.
The compiler replaces the function call statement with the function code itself(expansion)
and then compiles the entire code.
They run little faster than normal functions as function calling overheads are saved.
A function can be declared inline by placing the keyword inline before it.
inline void square(int a)
{ cout<<a*a; }
void main()
{ square(4); These two statements are translated to:
square(8); {cout<<4*4;} and {cout<<8*8;} respectively as the
} function is inline, its call is replaced by its body.
Q 11. Differentiate between Inline Functions and Non Inline Functions. Give a suitable example
using C++ code to illustrate the same.
void func1( )
{ X O4;
: }
void func2(
){:}
Which all members (data & functions) of classes X and Y can be accessed by main(),
func1(), func2( ) ?
Q 15. What are static class members? Explain with a suitable example.
TYPES OF CONSRUCTORS:
1. Default Constructor:
A constructor that accepts no parameter is called the Default Constructor. If you don't declare a
constructor or a destructor, the compiler makes one for you. The default constructor and
destructor take no arguments and do nothing. Default constructor provided by the compiler
initializes the object data members to default value.
class Cube
{ int side;
public:
Cube() //default constructor
{ side=10; }
};
int main()
{ Cube c;
cout << c.side;
}
OUTPUT: 10
2. Parameterized Constructors:
A constructor that accepts parameters is known as parameterized Constructors, also called as
Regular Constructors. Using this Constructor you can provide different values to data members
of the objects, by passing the appropriate values as argument.
class Cube
{ int side;
public:
Cube(int x)
{ side=x; }
};
int main()
{ Cube c1(10); Cube c2(20); Cube c3(30);
cout << c1.side; cout << c2.side; cout << c3.side;
}
OUTPUT : 10 20 30
Note: The argument to a copy constructor is passed by reference, the reason being that
when an argument is passed by value, a copy of it is constructed. But the copy constructor is
creating a copy of the object for itself, thus, it calls itself. Again the called copy constructor
requires another copy so again it is called. In fact it calls itself again and again until the
compiler runs out of the memory .so, in the copy constructor, the argument must be passed
by reference.
DESTRUCTORS:
A destructor is also a member function whose name is the same as the class name but is
preceded by tilde(“~”). It is executed automatically by the compiler when an object is
destroyed.
Destructors are usually used to deallocate memory and do other cleanup for a class
object and its class members when the object is destroyed.
A destructor is called for a class object when that object passes out of scope or is
explicitly deleted.
Example :
class TEST
{ int Regno,Max,Min,Score;
Public:
TEST( ) // Default Constructor
{ }
// Parameterized
TEST (int Pregno,int Pscore) Constructor
{
Regno = Pregno ;Max=100;Max=100;Min=40;Score=Pscore;
}
~ TEST ( ) // Destructor
{ Cout<<”TEST Over”<<endl;}
};
Note:
Constructors and destructors do not have return type, not even void nor can they return
values.
The compiler automatically calls constructors when defining class objects and calls
destructors when class objects go out of scope.
Constructors can be overloaded.
Q1. What are constructors and destructors? Give an example to illustrate the use of both.
Q2. Define Constructor overloading. Give an example.
Q3. Define Copy Constructor. Give an example.
Q4. Answer the questions (i) and (ii) after going through the following class :
class Test
{
char Paper[20];
int Marks;
public :
Test() //Function 1
{
strcpy(Paper, “Computer”);
Marks = 0;
}
Test(char P[]) //Function 2
{
strcpy(Paper, P);
Marks = 0;
}
Test(int M) //Function 3
{
strcpy(Paper, “Computer”);
Marks = M;
}
Test(char P[],int M) //Function 4
{
strcpy(Paper, P );
Marks =M;
}
};
Inheritance is the process by which new classes called derived classes are created
from existing classes called base classes.
The derived classes have all the features of the base class and the programmer can
choose to add new features specific to the newly created derived class.
The idea of inheritance implements the IS A relationship. For example, mammal IS-
A animal, dog IS-A mammal hence dog IS-A animal as well and so on.
For example, if the base class is MyClass and the derived class is sample it is specified as:
class sample: public MyClass
The above makes sample have access to both public and protected variables of base class
MyClass.
Consider a base class Shape and its derived class Rectangle as follows:
#include <iostream.h>
int main(void)
{
Rectangle Rect;
Rect.setWidth(5);
Rect.setHeight(7);
cout << "Total area: " << Rect.getArea() << endl; // Print the area of the object.
return 0;
}
When the above code is compiled and executed, it produces the following result:
Total area: 35
Modes of Inheritance:
When deriving a class from a base class, the base class may be inherited through public,
protected or private inheritance. The type of inheritance is specified by the access-specifier as
explained above.
We hardly use protected or private inheritance, but public inheritance is commonly used.
While using different type of inheritance, following rules are applied:
Public Inheritance: When deriving a class from a public base class, public members of
the base class become public members of the derived class and protected members of
the base class become protected members of the derived class. A base class's private
members are never accessible directly from a derived class, but can be accessed through
calls to the public and protected members of the base class.
Protected Inheritance: When deriving from a protected base class
public and protected members of the base class become protected members of the
derived class.
Private Inheritance: When deriving from a private base class,
public and protected members of the base class become private members of the
derived class.
We can summarize the different access types according to who can access them in the
following way:
A derived class inherits all base class methods with the following exceptions:
Constructors, destructors and copy constructors of the base
class. Overloaded operators of the base class.
The friend functions of the base class.
Types of Inheritance:
1. Single class Inheritance:
Single inheritance is the one where you have a single base class and a single derived class.
Class B
Sub/Derived/Child class
2. Multilevel Inheritance:
In Multi level inheritance, a subclass inherits from a class that itself inherits from another class.
3. Multiple Inheritance:
In Multiple inheritances, a derived class inherits from multiple base classes. It has properties
of both the base classes.
Class A Class B
Class C
4. Hierarchical Inheritance:
In hierarchical Inheritance, it's like an inverted tree. So multiple classes inherit from a
single base class.
Class A
Class B Class C
5. Hybrid Inheritance:
a. It combines two or more forms of inheritance .In this type of inheritance, we can have
mixture of number of inheritances but this can generate an error of using same name
function from no of classes, which will bother the compiler to how to use the functions.
b. Therefore, it will generate errors in the program. This has known as ambiguity or
duplicity.
c. Ambiguity problem can be solved by using virtual base classes
Class A
Class B Class C
Class D
A C++ class can inherit members from more than one class and here is the extended syntax:
class derived-class: access baseA, access baseB....
Where access is one of public, protected, or private and would be given for every base class and they
will be separated by comma as shown above. Let us try the following example:
#include <iostream.h>
class Shape // Base class Shape
{ public:
void setWidth(int w)
{ width = w; }
void setHeight(int h)
{ height = h; }
protected:
int width;
int height;
};
Q6. Consider the following and answer the questions given below.
class University
{ int NOC;
protected:
char Uname[25];
public:
University() { }
char State[25];
void Enterdata();
void Displaydata();
};
class College : public University
{ int NOD;
protected:
void Affiliation();
public:
College() { }
void Enrol();
void Show();
};
class Department : public College
{
char Dname[25];
int NOf;
protected:
void Affiliation();
public:
Department() { }
void Input();
void Display();
};
i) Which class’s constructor will be called first while declaring object of class Department?
ii) Which kind of inheritance is being depicted in the above example?
iii) If class college was derived privately from university, then, name members that could be
directly accesses through the object(s) of class Department.
iv) How many bytes does an object belonging to the class Department require?
v) Which is the base class and the derived class of class College.
Q7. Identify the syntax error(s), if any (give reason for error) :
Class ABC
{ int x = 10;
float y;
ABC ( ) { y=5; }
~ABC ( ) { }
};
void main( )
{ ABC a1, a2;
}
In Computer Science, a data structure is a particular way of storing and organizing data in a computer so that
it can be used efficiently. Different kinds of data structures are suited to different kinds of applications, and
some are highly specialized to specific tasks. For example, Stacks are used in function call during execution of
a program, while B-trees are particularly well-suited for implementation of databases. The data structure can
be classified into following two types:
Simple Data Structure: These data structures are normally built from primitive data types like integers,
floats, characters. For example arrays and structure.
Compound Data Structure: simple data structures can be combined in various ways to form more complex
structure called compound structures. Linked Lists, Stack, Queues and Trees are examples of compound data
structure.
Searching
We can use two different search algorithms for searching a specific data from an array
Linear search algorithm
Binary search algorithm
Linear search algorithm
In Linear search, each element of the array is compared with the given item to be searched for. This method
continues until the searched item is found or the last item is compared.
#include<iostream.h>
int linear_search(int a[], int size, int item)
{
int i=0;
while(i<size&& a[i]!=item)
i++;
if(i<size)
return i;//returns the index number of the item in the array else
return -1;//given item is not present in the array so it returns -1 since -1 is not a legal index number
}
void main()
{
int b[8]={2,4,5,7,8,9,12,15},size=8;
int item;
cout<<”enter a number to be searched
for”; cin>>item;
int p=linear_search(b, size, item); //search item in the array b
if(p==-1)
cout<<item<<” is not present in the array”<<endl;
else
cout<<item <<” is present in the array at index no “<<p;
}
In linear search algorithm, if the searched item is the first elements of the array then the loop terminates
after the first comparison (best case), if the searched item is the last element of the array then the loop
terminates after size time comparison (worst case) and if the searched item is middle element of the array
then the loop terminates after size/2 time comparisons (average case). For large size array linear search not
an efficient algorithm but it can be used for unsorted array also.
#include<iostream.h>
int binary_search(int a[ ], int size, int item)
{
int first=0,last=size-1,middle;
while(first<=last)
{
middle=(first+last)/2;
if(item==a[middle])
return middle; // item is found else if(item<
Class XII Computer Science (C++) Page 22
Smart Skills Sanskriti School
a[middle])
last=middle-1; //item is present in left side of the middle element
else
first=middle+1; // item is present in right side of the middle element
}
return -1; //given item is not present in the array, here, -1 indicates unsuccessful search
}
void main()
{
int b[8]={2,4,5,7,8,9,12,15},size=8;
int item;
cout<<”enter a number to be searched for”; cin>>item;
int p=binary_search(b, size, item); //search item in the array b
if(p==-1)
cout<<item<<” is not present in the array”<<endl;
else
cout<<item <<” is present in the array at index no “<<p;
}
Let us see how this algorithm work for item=12 Initializing first =0
; last=size-1; where size=8
Iteration 1
A[0] a[1] [2] a[3] a[4] a[5] a[6] a[7]
2 4 5 7 8 9 12 15
First=0, last=7
middle=(first+last)/2=(0+7)/2=3 // note integer division 3.5 becomes 3 value of a[middle]
i.e. a[3] is 7
7<12 then first= middle+1 i.e. 3 + 1 =4 iteration 2
A[4] a[5] a[6] a[7]
8 9 12 15
Assignment No : 4
Arrays
If the array is : 1, 2, 3
The resultant 2 D array is given below :
123120100
Assignment No : 5
Pointers
Q 7.Rewrite the following program after removing error(s), if any. Underline each correction.
a) # include<iostream.h>
struct triangle
{
int a,b,c;
}
void input (triangle *T)
{
T. a - =5;
T. b /=2; T.
c *= 0.5;
}
void display (triangle T)
{
cout<<T. a << “ : “;
cout<<T. b << “ : “;
cout<< T.c<< “ \n “;
}
void main ( )
{
triangle A = 10, 9, 9 ;
input(A);
display(A);
input(A);
display(A);
input(A);
display(A);
}
b) Void main( )
{ const int I; I =
20;
const int*ptr = &i ;
(*ptr++);
int j = 15;
ptr = &j;
}
b) # include<iostream.h>
void main ( )
{
int array [ ] = {2, 3, 4, 5 };
int *aptr=array;
int value = *aptr ; cout<<value<< “\n”;
value = *aptr++ ; cout<<value<< “\n”;
value = *aptr ; cout<<value<< “\n”;
value = *++aptr ; cout<<value<< “\n”;
}
c) # include<iostream.h>
void main( )
{
int arr [ ] = {4, 6, 10,
12}; int * ptr = arr;
for (int i = 1; i<= 3; i++)
{
cout<<*ptr << “#”;
ptr++;
}
for (i = 1; i<= 2; i++)
{
(*ptr)* = 3;
cout<<*ptr;
- -ptr ;
}
for (i = 0; i< 4; i++)
cout<<arr[i] << “@”;
cout<<endl;
}
d) void main()
{
int x [] = {10, 20, 30, 40, 50};
int *p, **q, *t;
p = x; t
= x+1;
q = &t;
cout<<*p<< “,” <<**q<< “,” << *t++;
}
e) # include<iostream.h>
# include<string.h>
class state
{
char *s_name;
int size;
public:
state( ){size =0;s_name = new car [size+1]; }
state( char *s)
{
size = strlen(s);
s_name = new car [size+1];
strcpy(s_name,s);
}
void display( )
{
cout<<s_name<<endl;
}
void replace(state & a, state &b)
{
size = a.size +b.size;
delete s_name;
s_name = new car [size+1];
strcpy(s_name, a.s_name);
strcat(s_name, b.s_name);
}
};
void main()
{
char * temp = “Delhi”;
state state1(temp), state2(“Mumbai”),
state3(“Nagpur”),s1,s2; s1.replace(state1, state2);
s1.replace(s1, state3);
s1.display( );
s2.display( );
}
Assignment No. 6
File Handling
Q 5.Assuming the class STOCK, write user defined functions in C++ to perform the following :
Q 6. Assuming the class employee given below, complete the definitions of the member
functions.
class employee
{
int emp_no;
char name[10];
float salary;
public :
void entry( ); // Input data from the user.
void show( ); // Display data on the screen.
void write_file( ) // Write data to the file from an object.
void read_file( ) // Read data from the file to an object.
};
Q 7. Given the binary file sports.dat, containing records of the following structure type:
Struct Sports
{
int code;
char Event[20];
char Participant[10][30];
int no_of_participants;
};
a) Write a function in C++ that would read contents from the file sports.dat
and create a file named athletic.dat copying only those records from
sports.dat where the event name is “Athletics”.
b) Write a function in C++ to update the file with the new value of
no_of_participants. The value of code and no_of_participants are read during
the execution of the program.
Q 8. Write a function in C++ to print the count of the world the as anindependent word in
the text file story.txt.
For Example , if the content of the file story.txt is:
There was a monkey in the zoo. The monkey was very naughty.
Then the output of the program should be 2.
Q 10. Observe the program segment given below carefully and fill the blanks marked as
statement 1 and statement 2 using seekg( ) and seekp( )functions for performing the
required task.
# include <fstream.h>
class Item
{
int Ino;
char item[20];
public :
// Function to search and display the content from a particular record number
void search (int);
// Function to modify the content of a particular record number
void Modify (int);
};
void item :: Search( int RecNo)
{
fstream file;
file.open (“stock.dat”, ios::binary|ios::in);
________________________ //Statement 1
file.read((char*)this, sizeof(item));
cout<<Iino<< “ “<<Item;
file.close ( );
}
void item :: Modify( int RecNo)
{
fstream file;
file.open (“stock.dat”,
ios::binary|ios::in|ios::out); cout>>Ino;
cin.getline(item,20);
________________________ //Statement 2
file.write((char*)this, sizeof(item));
cout<<ino<< “ “<<Item;
file.close ( );
}
};
Q 11. Following is the structure of each record in the data file named “Product.dat”.
struct Product
{
char P_code[10];
char P_Description [10];
int stock;
};
Write a function in C++ to update the file with a new value of Stock. The stock and
the P_code, whose stock is to be updated are read during the execution of the
program.
Q 12. Following is the structure of each record in the data file named “Flights.dat”.
struct Flight
{
int Fl_No;
char Starting [20];
char Ending [20];
};
Write a function in C++ to delete a record from the file. The Fl_No, whose record is to
be deleted is read during the execution of the program.
Assignment No : 7
Linked list, Stacks and Queues
Q 12. Each node of a STACK contains the following information, in addition to the required
pointer field :
a. acc_no
b. acc_name
Give the structure of node for the linked stack in question
TOP is a pointer which points to the topmost node of the STACK. Write the
following functions.
i) PUSH( ) – To push a node to the STACK which is allocated dynamically.
ii) POP ( ) – To remove a node from the STACK and release the memory.
Q 14. Solve the following postfix expression using the stack method, for the given values.
AB+C*DE/+
A=3, B=5, C=2, D=8, E=4
Show stack after each pass.
Q 15. Solve the following postfix expression using a stack. TRUE FALSE and FALSE
TRUE not or and
Show the contents of stack after execution of each operation:
{
int front, rear; //the queue pointers
int que [15]; // the elements
void err_rep( int e_enum) { cout<< msg[e_enum]; }
public :
queue ( ) { front=-1;rear=-1} //function to initialize the queue pointers
void inst(int); // add a new value in queue
void remove ( ); // remove an element from the queue &
// display it
};
Define the member functions inst( ) and remove( ) outside the class, the functions
should invoke err_rep( ) in case of overflow/ underflow.
Q 18. Write functions to perform insert and delete operations on a circular queue of integers.
(Array Implementation)
Assignment No : 8
Boolean Algebra
1. (a) State Distributive law and verify the same using truth table.
(b)Write the equivalent Canonical Sum of Product expression for the following Product
of Sum Expression
F(X,Y,Z)=∏(1, 3, 6, 7)
(c)Write the equivalent Boolean Expression for the following Logic Circuit.
(c) Represent the Boolean expression x.y’ + y.z’ with the help of NAND gates only.
(d) Obtain simplified form of the following Boolean expression using Karnaugh Map
(e) Write the POS form of Boolean Function F(U,V,W) which is represented in the truth table
as :
U V W F
0 0 0 0
0 0 1 0
0 I 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
Assignment No. 9
Communication And Network Concepts
Q 5.What is the purpose of having web browser? Name any one commonly used browser.
Q 6.Give two major reasons to have network security.
Q 7.Indian Public School in Darjeeling is setting up the network between its different wings. It
has four wings named as Senior (S), Junior(J), Admin(A) and Hostel(H):
Senior Junior
(S) (J)
Admin Hostel
(A) (H)
Number of Computers :
Wing A 10
Wing S 200
Wing J 100
Wing H 50
a. Suggest a suitable Topology for networking the computer of all the wings.
b. Suggest the most suitable wing to house the server of this school. Justify your
answer.
c. Suggest the placement of the following devices with justification :
i. Repeater
ii. Hub/ Switch
d. Mention an economic technology to provide internet accessibility to all the wings.
Q 8.“United Group” is planning to start their offices in four cities of India.. The company has
planned to set up their head office in Goa in three locations and have named their Goa
offices as “Front Office”, “Back Office” and “Work office”. The company’s regional
offices are located at “Pune”, “Mumbai” and “Hydrabad”.
A rough layout of the same is as follows:
GOA
FRONT
BACK
OFFICE
OFFICE
WORK
OFFICE
Pune MumbaiOff
ice
Office
Hyderabad
Office
Number of Computers :
Front Office 150
Back Office 70
Work Office 20
Pune Office 65
Mumbai Office 90
Hyderabad Office 100
a. Suggest a network type(out of LAN, MAN, WAN) for connecting each of the following set of
their offices :
Front Office and Back Office
Front Office and Pune Office
b. Which device will you suggest to be procured by the company for connecting all the
computers within each of their offices out of the following devices?
Modem
Telephone
Switch/ Hub
c. Which of the following communication media, will you suggest to be procured by the
company for connecting their local offices in Goa for very effective and fast communication ?
Ethernet Cable
Optical Fiber
Telephone Cable
d. Suggest a cable/ Wiring layout for connecting the company’s local offices located in Goa.
Also, suggest an effective method/ technology for connecting the company’s regional office
at “Pune”, “Bombay” and “Hydrabad”.
Q 2.What is a relation?
i. Attribute
ii. Tuple
iii. Foreign Key
iv. Data redundancy
v. DDL
vi. DML
Q.2 Insert the following records in the above table (write commands for any three):
Acc_no CName Address Ph_No Amount DOO Type
1 Karan 22/7, green Park, Delhi 321345 45000 12/01/1975 S
2 Puneet 3/1, Friends colony, Delhi 324567 89000 01/01/1985 R
3 Anirban 12/7, GK-1, New Delhi 432664 78000 11/10/1988 C
4 Yatin 11, A Block, Rohini, Delhi 256997 100000 06/08/1999 S
5 Sonia 32/4, green Park, Delhi 123456 8921 03/08/1998 S
6 Sophia 13/11, Friends colony, Delhi NULL 45697 05/08/1996 R
7 Nikhil 112/7, GK-1, New Delhi 234890 14752 12/01/1975 C
8 Tarun 21, A Block, Rohini, Delhi NULL 5500 01/01/1986 R
9 Jisha 113, A Block, Rohini, Delhi 126790 78451 11/10/1978 R
10 Tanmay 1/7, GK-1, New Delhi 345678 70000 06/08/1989 S
Considering the above table write SQL commands for the following
: Q 3. Display the record of all the customers.
Q 4. Display the record of all the customers sorted in descending order of their
amounts.
Q 5. To count total number of customers for each type.
Q 6. To display the total money deposited in the bank.
Q 7. To list out the names of all the customers, whose name starts with S.
Q 8. To display the Acc_no and names of all those customers, who do not have phone.
Q 9. To display total amount in each type of account.
Q 10. To list the names and addresses of all the customers staying in Rohini.
Q.2 Insert the following 10 records in the above table (Write commands for any three):
Q 4. Display data of all the products whose quantity is between 170 and 370.
Q 5. Give Sname for the products whose name starts with ‘C’.
Q 6. Sname, Pname,Price for all the products whose quantity is less than 200.
Q 7. To list out the names of all the products, whose name ends with S.
Q 8. To display S_No, Pname, Sname, Qty in descending order of qty.
Q 10. To list the Snames, Qty, Price and value (Qty*Price) of each product.
Q.2 Insert the following 10 records in the above table (Write commands for any three) :
Q 3. To display all the information about the swimming coaches in the club.
Q 4. Display the names of all the coaches with their date of appointment in descending
order.
Q 5. To display a report, showing coach name, pay, age and bonus(15% of pay) for all the coaches.
Q 6. To display the total number of coaches in the club.
Q 7. To count the total number of male and female coaches.
Q 8. To display total salary given to all the coaches.
Q 9. To display the salaries of all the coaches appointed after {01/01/1998}.
Q 10. To increment the Pay of all the coaches by 500, earning less than 1500.
Q.2 Insert the following 10 records in the above table (Write commands for any three ) :
V_no VName Address Ph_No Age
1 Kiran 22/7, C R Park, Delhi 321345 32
2 Puneeta 113/1, Friends colony, Delhi 324567 18
3 Anubhav 12/7, GK-1, New Delhi 432664 47
4 Yatin 11, A Block, Rohini, Delhi 256997 22
5 Suniana 32/4, green Park, Delhi 123456 32
6 Sophia 13/11, Friends colony, Delhi NULL 89
7 Nakul 112/7, GK-1, New Delhi 234890 41
8 Tarang 21, A Block, Rohini, Delhi NULL 85
9 Nisha 113, A Block, Rohini, Delhi 126790 78
10 Tanmay 1/7, GK-1, New Delhi 345678 65
Q.2 Insert the following 10 records in the above table (write commands for any three) :
No Name Stipend Stream AvgMark Grade
1 Diwakar 400.00 Medical 78.5 A
2 Deepa 550.00 Commerce 89.5 A
3 Divya 600.00 Non 68.6 B
Medical
4 Arun 475.00 Commerce 49.0 C
5 Sabina 425.00 Medical 40.25 C
6 John 600.00 Humanities 94.5 B
7 Robert 500.00 Commerce 88.5 A
8 Rubina 550.00 Non 92.5 A
Medical
9 Vikas 575.00 Medical 67.5 B
10 Mohan 600.00 Humanities 73.0 A
Program List
General Instructions:
1. Practical files should contain program listings and outputs.
2. Each program should be headed with Program number.
3. Header comment of each program should contain :
Name of the Program : _______________
Programmers Name :_______________
Date : _______________
Rollno int
Name char [20]
Marks float[5]
Total float
Per float
DOB date ( use date.h)
Now, Write the following functions :
1. To input rollno, name, marks in 5 subjects, date (use
input and validate( ) from date.h ) and calculate
total & percentage of a student
2. To display the data of the students.
Write a menu driven function to execute the above
functions for 5 students.
4 Define a class Account with the following
Data members :
Member Functions :
1) To input the data members.
2) To display the data members.
3) To and write the data to a Binary File
4) To read the data from the Binary file
www.mycbseguide.com
www.tutorialspoint.com
www.cplusplus.com/