27

Click here to load reader

Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Embed Size (px)

Citation preview

Page 1: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Chapter Wise Questions C++ - 1. Introduction to OOP using C++Object Oriented Programming Concepts

Short Answer Questions Q1. Define object.Q2. Define class.Q3. Define data abstraction.Q4. What is inheritance?Q5. Define modularity.Q6. Define encapsulation.Q7. What is polymorphism?Q8. How polymorphism is implemented in C++?Q9. How inheritance is implemented in C++?Q10. What is data hiding? How it is implemented in C++?Q11. How data abstraction can be implemented in C++?Q12. What is programming paradigm?Q13. What is procedural programming paradigm?Q14. What are the advantages of OOP?Q15. What do you understand by functional overloading? Give an example illustrating its use in a C++

program.

CLASSES AND OBJECTS SOME MPORTANT QUESTIONS TO REFRESH THE CONCEPTQ1. Write four attributes associated with declaration of classes.Q2. Define data members and member functions.Q3. Write the scope rules of members of a class. Q4. How many types of functions are used in a class?Q5. When will you make a function inline?Q6. What is scope resolution operator?Q7. Define static data members.Q8. How is memory allocated to a class and its objects?

BOARD PATTERN QUESTIONS:Long Answer Questions (4 marks)Q1. Define a class employee with the following specifications; Private members of class employee : empno integer ename 20 characters basic,hra,da float netpay float calculate( ) A function to calculate basic + hra + da with float return type Public member functions of class employee : havedata( ) function to accept values for empno, sname, basic , hra ,da and invoke calculate( ) to calculate netpay dispdata( ) function to display all the data members on the screen .

Q2. Define a class Student for the following specifications : Private members of the Student are : roll _ no integer name array of characters of size 20 class _ st array of characters of size 8 marks array of integers of size 5 percentage float calculate that calculates the percentage marks Public members of the Student are : readmarks reads mark and invoke the calculate function displaymarks prints the data.

Page 2: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Q3. Define a class DONOR with the following specifications : Private : Donor number integer Name 20 characters Blood group 2 characters Public : Input( ) A function to accept all the information Output( ) A function to display all the information Checkgroup( ) A function with char * return to return Blood Group Define both the number functions with their given description.

Q4. Define a class TEST in C++ with following description: Private Members

TestCode of type integer Description of type string NoCandidate of type integer CenterReqd (number of centers required) of type integer A member function CALCNTR() to calculate and return the number of centers as

(NoCandidates/100+1) Public Members

• A function SCHEDULE() to allow user to enter values for TestCode, Description, NoCandidate & call function CALCNTR() to calculate the number of Centres

• A function DISPTEST() to allow user to view the content of all the data members

Q5. Define a class in C++ with following description:Private Members• A data member Flight number of type integer• A data member Destination of type string• A data member Distance of type float• A data member Fuel of type float• A member function CALFUEL() to calculate the value of Fuel as per the following criteria

Distance Fuel<=1000 500more than 1000 and <=2000 1100more than 2000 2200

Public Members• A function FEEDINFO() to allow user to enter values for Flight Number, Destination,

Distance & call function CALFUEL() to calculate the quantity of Fuel• A function SHOWINFO() to allow user to view the content of all the data members

CONSTRUCTOR AND DESTRUCTORSOME MPORTANT QUESTIONS TO REFRESH THE CONCEPT

Q1. What is constructor?Q2. What is destructor?Q3. What are different types of constructors?Q4. What is default constructor? Q5. What is parameterized constructor? Q6. What is copy constructor?

BOARD PATTERN QUESTIONS -Short Answer Questions ( 2 marks)

Note : Two options with the following pattern are generally asked in the Board Exam. Various optional questions are given below.

Q7. Answer the following questions after going through the following class:

Page 3: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

class Seminar{

int Time;public:

Seminar(); //Function 1void Lecture() //Function 2{cout<<”Lectures in the seminar on”<<end1;}Seminar(int); //Function 3Seminar(Seminar &abc); //Function 4~Seminar() //Function 5{ cout<<”Vote of thanks”<<end1;}

};

(i) In Object Oriented Programming, what is Function 5 referred as and when does it get invoked/called?

(ii) In Object Oriented Programming, which concept is illustrated by Function 1, Function 3 and Function 4 all together?

(iii) Which category of constructor - Function 1 belongs to? Write an example illustrating the calls for Function 1.

(iv) Which category of constructor - Function 3 belongs to? Write an example illustrating the calls for Function 3.

(v) Which category of constructor - Function 4 belongs to? Write an example illustrating the calls for Function 4.

(vi) Write an example illustrating the calls for Function 3 explicitly. (vii) Write an example illustrating the calls for Function 4 explicitly. (viii) Write the complete definition for Function 1 to initialize Time as 30. (ix) Write the complete definition for Function 3 to initialize Time with Mytime as parameter to

the Function 3. (x) Write the complete definition for Function 4.

Q8. Answer the following questions after going through the following class:class Complex{

int x;int y;

public:Complex(); //Function 1void disp() //Function 2{cout<<”The Complex number is : “<<x<<” + “<<y<<”i”<<end1;}Complex(int, int); //Function 3Complex(Complex &abc); //Function 4

};

(i) Which category of constructor - Function 1 belongs to? Write an example illustrating the calls for Function 1.

(ii) Which category of constructor - Function 3 belongs to? Write an example illustrating the calls for Function 3.

(iii) Which category of constructor - Function 4 belongs to? Write an example illustrating the calls for Function 4.

(iv) Write an example illustrating the calls for Function 3 explicitly. (v) Write an example illustrating the calls for Function 4 explicitly. (vi) Write the complete definition for Function 1 to initialize x as 10 and y as 20. (vii) Write the complete definition for Function 3 to initialize the data members with p and q as

parameters to the Function 3. (viii) Write the complete definition for Function 4.

Inheritance

Page 4: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

SOME MPORTANT QUESTIONS TO REFRESH THE CONCEPTQ1. Write the reasons behind the introduction of inheritance in OOP.Q2. What are the different forms of inheritance?Q3. How does the access of inherited members depend upon their access specifiers and the visibility

modes of the base class?Q4. Write the different ways of accessibility of base class members.Q5. How is the size of a derived class object calculated?Q6. In what order are class constructors and class destructors called when a derived class object is created

or destroyed?

BOARD PATTERN QUESTIONS Long Answer Questions (4 Marks)

Q1. Answer the questions (i) to (iv) based on the following:

i) Write the member(s) that can be accessed from the object of bus. ii) Write the data member(s) that can be accessed from the function displaydata( ). iii) How many bytes are required by an object of bus and heavyvehicle classes respectively? iv) Is the member function outputdata( ) accessible to the objects of the class heavyvehicle?Q2. Answer the questions (i) to (iv) based on the following:

(i) Write the members which can be accessed from the member functions of class human.(ii) Write the members, which can be accessed by an object of class human.(iii) What is the size of an object (in bytes) of class human?(iv) Write the class(es) which objects can access read() declared in livingbeing class.

Q3. Answer the questions (i) to (iv) based on the following:

(i) In case of the class father, what is the base class of father and what is the derived class of father?(ii) Write the data member(s) that can be accessed from function dispdata().(iii) Write the member function(s), which can be accessed by an object of mother class.(iv) Is the member function outputdata() accessible to the objects of father class?

Q4. Answer the questions (i) to (iv) based on the following:

class vehicle { int wheels; protected: int passenger; public: void inputdata( ); void outputdata( ); };

class bus : private heavyvehicle { char make[20]; public: void fetchdata( ); void displaydata( ); };

class livingbeing{

char specification[20];int averageage;

public:void read();void show();

};

class human : public ape{

char race[20];char habitation[30];

public:void readhuman();void showhuman();

};

class parent{

char name[20];protected:

int son;public:

void inputdata();void outputdata();

};

class mother : public father{

int child;public:

void fetchdata();void dispdata();

};

class person{

char name[20], address[20];

class doctor : public person{

char speciality[20];

class father : protected parent{

int daughter;protected:

int baby;public:

void readdata();void writedata();

};

class heavyvehicle : protected vehicle { int diesel_petrol; protected: int load; public: void readdata(int, int); void writedata( ); };

class ape : private livingbeing{ int no_of_organs;int no_of_bones; protected:

int iq_level; public:

void readape();void showape();

};

class client : private person{

Page 5: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

(i) What type of inheritance is depicted by the above example?(ii) Write the member functions, which can be called by the object of class client.(iii) What is the size in bytes of the object of class doctor and client respectively?(iv)Write the data members, which can be used by the member functions of the class doctor.

Q5. Answer the questions (i) to (iv) based on the following:

(i) Write the names of data members, which are accessible from object of class employee.(ii) Write the names of all the member functions which are accessible from object of class person.(iii) Write the data members which are accessible from member functions of class employee.(iv)How many bytes are required by an object belonging to class employee?

Q6. Answer the questions (i) to (iv) based on the following:

(i) Write the names of data members, which are accessible from objects belonging to class AUTHOR.(ii) Write the names of all the members which are accessible from member functions of class AUTHOR.(iii) How many bytes are required by an object belonging to class AUTHOR?

(v) Write the sequence of the constructors’ invocation when the object of author is created.

Q7. Answer the questions (i) to (iv) based on the following:

(i) Write the names of data members which are accessible from objects belonging to class CUSTOMER.

(ii) Write the member functions that are accessible from objects belonging to class SALESMAN.(iii) Write the names of all the members which are accessible from member functions of class SHOP.

class person{

char name[20], address[20];

class doctor : public person{

char speciality[20];

class author{

char name[12];double royalty;

protected:void register();

public:author(){};void enter();void display();

};

class employee : private author, public person{

int ecode;char dept[30];

public:employee(){};void start();void show();

};

class client : private person{

class person{

char address[20];protected:

float salary;public:

person(){};void havelt();void givelt();

};

class PUBLISHER{ char Pub[12];

double Turnover;protected:

void Register();public:

PUBLISHER();void Enter();void Display();

};

class BRANCH{ char CITY[20];protected:

float Employees;public:

BRANCH();void Haveit();void Giveit();

};

class AUTHOR: private BRANCH, public PUBLISHER{ int Acode;char Aname[20];

float Amount;public:

AUTHOR();void Start();void Show();

};

class CUSTOMER{

int Cust_no;char Cust_Name[20];

protected:void Register();public:

CUSTOMER();void Status();

};

class SALESMAN{

int Salesman_no;char Salesman_Name[20];

protected:float Salary;

public:SALESMAN();void Enter();void Show();

};

class SHOP : private CUSTOMER , public SALESMAN{

char Voucher_No[10];char Sales_Date[8];

public:SHOP();void Sales_Entry();void Sales_Detail();

};

Page 6: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

(iv) How many bytes will be required by an object belonging to class SHOP?

Data Structure & Pointers Address Calculation

Short Answer Questions ( 3 marks)Formulae of Row Major & Column Major are used in the given questions. Kindly go through it.

Q1. An array x[30][10] is stored in the memory with each element requiring 4 bytes of storage. If the base address of x is 4500, find out memory locations of x[12][8] and x[2][4], if the content is stored along the row.

Q2. An array P[20][30] is stored in the memory along the column with each of the element occupying 4 bytes, find out the Base Address of the array, if an element P[2][20] is stored at the memory location 5000.

Q3. An array ARR[5][25] is stored in the memory with each element occupying 4 bytes of space. Assuming the base address of ARR to be 1000, compute the address of ARR[5][7], when the array is stored as : (i) Row wise (ii) Column wise.

Q4. An array S[40][30] is stored in the memory along the row with each of the element occupying 2 bytes, find out the memory location for the element S[20][10], if an element S[15][5] is stored at the memory location 5500.

Q5. An array P[20][30] is stored in the memory along the column with each of the element occupying 4 bytes, find out the memory location for the element P[5][15], if an element P[2][20] is stored at the memory location 5000.

Static Allocation of ObjectsShort Answer Questions ( 2 marks)Note : Practice the way to write the function definition where array and its size are passed as arguments.

Practice with the concepts of accessing the elements of the one / two dimensional array. Apply the suitable logic to solve the given problem and write the coding of it.

Q1. Write a function in C++ to find sum of rows from a two dimensional array. Q2. Write a function in C++ to find the sum of both left and right diagonal elements from a two

dimensional array (matrix).Q3. Write a function in C++ which accepts an integer array and its size as arguments and replaces

elements having even values with its half and elements having odd values with twice its value. eg: if the array contains : 3, 4, 5, 16, 9

then the function should be rearranged as 6, 2,10,8, 18Q4. Write a user defined function in C++ which intakes one dimensional array and size of array as

argument and display the elements which are prime.If 1D array is 10 , 2 , 3 , 4 , 5 , 16 , 17 , 23 Then prime numbers in above array are: 2 , 3 , 5, 17, 23

Q5. Write a function in C++ which accepts an integer array and its size as arguments/parameters and exchanges the values at alternate locations. example : if the array is 8,10,1,3,17,90,13,60 then rearrange the array as 10,8,3,1,90,17,60,13

Short Answer Questions ( 3 marks)Q1. Write a function in C++ to merge the contents of two sorted arrays A & B into third array C.

Assuming array A is sorted in ascending order, B is sorted in descending order, the resultant array is required to be in ascending order.

Q2. Given two arrays of integers x and y of sizes m and n respectively. Third array of integers z has m+n size. These are passed as the arguments to the function EXCHANGE(). Write a function named EXCHANGE() which will produce the elements to the third array named z, such that the following sequence is followed: (i) All odds numbers of x from left to right are copied into z from left to right. (ii) All even number of x from left to right are copied into z from right to left. (iii) All odd numbers of y from left to right are copied into z from left to right.

Page 7: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

(iv) All even number of y from left to right are copied into z from right to left. e.g.: x is {3,2,1,7,6,3} and y is {9,3,5,6,2,8,10} then z = {3,1,7,3,9,3,5,10,8,2,6,6,2}

Q3. Write function SORTPOINTS() in c++ to sort an array of structure Game in descending order of points using Bubble Sort Note: Assume the following definition of structure Game struct Game { long PNo; // Player Number char PName[20]; long points; };

Q4. Write a function in C++ which accepts an integer array and its size as arguments and assign the elements into a two dimensional array of integers in the following format If the array is 1,2,3,4,5,6 if the array is 1,2,3 The resultant 2D array is The resultant 2D array is 1 2 3 4 5 6 1 2 3 0 1 2 3 4 5 0 1 2 0 0 1 2 3 4 0 0 1 0 0 0 1 2 3 0 0 0 0 1 2 0 0 0 0 0 1

Q5. Write a function in C++ which accepts an integer array of double dimensional with its size as arguments and displays the total numbers of odd, even and prime numbers in the array. Example : if the following integer array will be passed to the function, i.e.6 4 13 19 57 3 8 11 519 12 23 4 621 29 18 9 1028 5 12 2 6Then the output should be : The total odd numbers are : 13

The total odd numbers are : 12The total Prime numbers are : 10

Dynamic Allocation of ObjectsLong Answer Questions ( 4 marks )Note : Insertion at the beginning of Linked List (Push operation in Stack), Insertion at the end of Linked

List (Insertion in a Queue), Deletion from the beginning of Linked List (Pop operation in Stack as well as Deletion of node in a Queue) are in the syllabus. So, only the logic of these three functions should be practiced. The logic and the way to solve these functions are given below. Practice them.

Q1. Write a function in C++ to delete a node containing customer’s information, from a dynamically allocated Queue of Customers implemented with the help of the following structure:struct Customer{

int CNo;char CName[20];Customer *Link;

};

Q2. Write a function in C++ to delete a node containing Book’s information, from a dynamically allocated Stack of Books implemented with the help of the following structure.struct Book{

int BNo;char BName[20];

Page 8: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Book *Next;};

Q3. Write a function in C++ to perform a PUSH operation in a dynamically allocated stack considering the following:

struct node { int x,y;

node *Link; };

Q4. Write a function in C++ to perform Insert operation in a dynamically allocated Queue containing names of students.struct stud{

char Name[20];stud *Link;

};

Q5. Write a function in C++ to perform Push operation on a dynamically allocated Stack containing real numbers. struct NODE

{float Data; NODE *Link;

};

Infix & Postfix ExpressionsShort Answer Questions ( 2 marks)

(Postfix to Infix)Q1. Evaluate the following postfix notation of expression:

15 3 2 + / 7 + 2 *

Q2. Evaluate the following postfix notation of expression:True, False, AND, True, True, NOT, OR, AND

Q3. Evaluate the following postfix notation of expression:25 8 3 – / 6 * 10 +

(Infix to Postfix)Q4. Convert A + ( B * C – ( D / E )) * F into postfix form showing stack status after every step.

Q5. Convert NOT A OR NOT B AND NOT C into postfix form.

DATA FILE HANDLING

Very Short Answer Questions ( 1 mark)

Q1. Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekg()/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 of a particular record void Search(int ); //Function to modify the content of a particular record number void Modify(int);

};void Item::Search(int RecNo)

Page 9: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

{fstream File;File.open(“STOCK.DAT”,ios::binary|ios::in);______________________ //Statement 1File.read((char*)this,sizeof(Item));cout<<Ino<<”==>”<<Item<<endl;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 2File.write((char*)this,sizeof(Item));File.close();

}

Page 10: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Q2. Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekg() and tellg() functions for performing the required task.

#include <fstream.h>class Employee{int Eno;char Ename[20];public://Function to count the total number of recordsint Countrec(); };int Item::Countrec(){

fstream File;File.open(“EMP.DAT”,ios::binary|ios::in);______________________ //Statement 1

int Bytes = ______________________ //Statement 2

int Count = Bytes / sizeof(Item);File.close();return Count;

}

Q3. Observe the program segment given below carefully and answer the following:-

#include <fstream.h>class stud{

int rno; char name[20];public:

void enroll(); void disp();long rrno(){return rno;}

};void update(long i){

fstream File;File.open(“STOCK.DAT”,ios::binary|ios::in);Stud s1;int record=0,found=0;while(File.read((char*)&s1,sizeof(stud))){ if(i == s1.rrno())

{ cout<<”enter new score”;S1.enroll();______________________ //Statement 1______________________ //Statement 2

Found=1;}Record++;

}If(found==1)

Cout<<”record update”;File.close();

}Write the statement 1 to position the file pointer at the beginning of the record & statement 2 to write the record.

Page 11: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Q4. A file named as “STUDENT.DAT” contains the student records, i.e. objects of class student. Assuming that the file is just opened through the object FILE of fstream class, in the required file mode, write the command to position the put pointer to point to the beginning of the second record from the last record.

Q5. A file named as “EMPLOYEE.DAT” contains the student records, i.e. objects of class employee. Assuming that the file is just opened through the object FILE of fstream class, in the required File mode, write the command to position the get pointer to point to eighth record from the beginning.

Short Answer Questions ( 2 marks)Q1. Write a function in C++ to count the number of lowercase alphabets present in a text file

“BOOK.TXT”;Q2. Write a function in C++ to count the number of alphabets present in a text file “DATA.TXT”.Q3. Write a function in C++ to count the number of vowels present in a text file “STORY.TXT”.Q4. Write a function in C++ to count the number of words in a text file NOTES.TXT.Q5. Write a function in C++ to count the number of lines present in a text file “STORY.TXT”.

Short Answer Questions ( 3 marks)Q1. Write a function in C++ to add more new objects at the bottom of a binary file STUDENT.DAT”,

assuming the binary file is containing the objects of the following class.class STUD{

int Rno;char Name[20];

public:void Enter(){cin>>Rno;gets(Name);}void Display(){cout<<Rno<<Name<<endl;}

};Q2. Write a function in C++ to read & display the details of all the members whose membership type is

‘L’ or ‘M’ from a binary file “CLUB.DAT”. Assume the binary file contains object of class CLUB.class CLUB{

int mno;char mname[20];char type;

public:void register ( );void dis();char whattype( ){ return type;}

};Q3. Given a binary file PHONE.DAT containing records of the following structure type.

class Phonlist{

char add;char Name[20];

char area[5];public:

void register(); void show();

int check(char ac[ ]){

return strcmp(area,ac)}

};Write a function TRANSFER( ) in C++, that would copy all records which are having area as ”DEL” from PHONE.DAT to PHONBACK.DAT.

Page 12: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Q4. Write a function in C++ to modify the name of a student whose roll number is entered during the execution of the program. Search the accepted roll number from a binary file “STUDENT.DAT” and modify the name, assuming the binary file is containing the objects of the following class.class STUD{

int Rno;char Name[20];

public:int srno(){ return Rno;}void Enter(){gets(Name);}void Display(){cout<<Rno<<Name<<endl;}

};Q5. Given a binary file PHONE.DAT, containing records of the following structure type class Phonlist

{ char Name[20]; char Address[30]; char AreaCode[5]; char PhoneNo[15]; public: void Register(); void Show(); int CheckCode(char AC[]) { return strcmp(AreaCode,AC); } }; Write a function TRANSFER ( ) in C++, that would copy all those records which are having AreaCode as “DEL” from PHONE.DAT to PHONBACK.DAT.

Databases and SQLShort Answer Questions

Q1. What is a database system? What are the advantages provided by a database system?

Q2. What are the various levels of database abstraction in a database system?

Q3. What is Data Independence? What are the levels of Data Independence?

Q4. What is a view? How is it useful?

Q5. What is relation? Define the relational data model?

Q6. Define : (i) Tuple (ii) Attribute (iii) Degree (iv) Cardinality.

Q7. What do you understand by Primary Key & Candidate Keys?

Q8. Define alternate key. What do you understand by foreign key?

Q9. What is Data Definition Language? Give examples of some DDL commands.

Q10. What is Data Manipulation Language? Give examples of some DML commands.

Q11. What is SQL? Write the various processing capabilities of SQL.

Page 13: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

SYNTAX of some SQL COMMANDS :1. SELECT column list FROM <table name> WHERE <condition> GROUP BY <column name(s)>

HAVING <search condition> ORDER BY column name;2. INSERT INTO <table name> [<column list>] VALUES ( <value>, <value>, ...);3. DELETE FROM <table name> [WHERE <predicate>];4. UPDATE <table name> SET <column name> = <new value> [WHERE <predicate>];5. CREATE TABLE <table name> (<column name> <data type> [(size)] <column constraint>,

<column name> <data type> [(size)] <column constraint>, ... <table constraint> (<column name> [<column name> ...]) ...);

6. CREATE VIEW <view name> [(<column name>, <column name>,...)] AS <SELECT command>;7. ALTER TABLE <table name> ADD / MODIFY <column name> <data type> <size>;8. DROP TABLE <table name>;9. DROP VIEW <view name>;

Long Answer Questions

Q1. Consider the following tables ACTIVITY and COACH. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).

Table: ACTIVITYACode ActivityName ParticipantsNum PrizeMoney ScheduleDate

1001 Relay 100x4 16 10000 23-Jan-20041002 High jump 10 12000 12-Dec-20031003 Shot Put 12 8000 14-Feb-20041005 Long Jump 12 9000 01-Jan-20041008 Discuss Throw 10 15000 19-Mar-2004

Table: COACHPCode Name ACode1 Ahmad Hussain 10012 Ravinder 10083 Janila 10014 Naaz 1003

(i) To display the name of all activities with their Acodes in descending order.(ii) To display sum of PrizeMoney for each of the Number of participants groupings (as shown in

column ParticipantsNum 10,12,16).(iii) To display the coach’s name and ACodes in ascending order of ACode from the table

COACH.(iv) To display the content of the GAMES table whose ScheduleDate earlier than 01/01/2004 in

ascending order of ParticipantNum.(v) SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY;(vi) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM ACTIVITY;(vii) SELECT SUM(PrizeMoney) FROM ACTIVITY;(viii) SELECT DISTINCT ParticipantNum FROM COACH;

Q2. Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).

Table: GAMESGCode GameName Number PrizeMoney ScheduleDate101 Carom Board 2 5000 23-Jan-2004102 Badminton 2 12000 12-Dec-2003103 Table Tennis 4 8000 14-Feb-2004105 Chess 2 9000 01-Jan-2004108 Lawn Tennis 4 25000 19-Mar-2004

Page 14: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Table: PLAYERPCode Name Gcode1 Nabi Ahmad 1012 Ravi Sahai 1083 Jatin 1014 Nazneen 103

(i) To display the name of all Games with their Gcodes.(ii) To display details of those games which are having PrizeMoney more than 7000. (iii) To display the content of the GAMES table in ascending order of ScheduleDate.(iv) To display sum of PrizeMoney for each of the Number of participation groupings (as shown in

column Number 2 or 4).(v) SELECT COUNT(DISTINCT Number) FROM GAMES;(vi) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;(vii) SELECT SUM(PrizeMoney) FROM GAMES;(viii) SELECT DISTINCT Gcode FROM PLAYER;

Q3. Consider the following tables HOSPITAL. Give outputs for SQL queries (i) to (iv) and write SQL commands for the statements (v) to (viii).

No Name Age Department Dateofadmin Charge Sex1 Arpit 62 Surgery 21/01/06 300 M2 Zayana 18 ENT 12/12/05 250 F3 Kareem 68 Orthopedic 19/02/06 450 M4 Abhilash 26 Surgery 24/11/06 300 M5 Dhanya 24 ENT 20/10/06 350 F6 Siju 23 Cardiology 10/10/06 800 M7 Ankita 16 ENT 13/04/06 100 F8 Divya 20 Cardiology 10/11/06 500 F9 Nidhin 25 Orthopedic 12/05/06 700 M10 Hari 28 Surgery 19/03/06 450 M

(i) Select SUM(Charge) from HOSPITAL where Sex=’F’; (ii) Select COUNT(DISTINCT Department ) from HOSPITAL;(iii) Select SUM(Charge) from HOSPITAL group by Department;(iv) Select Name from HOSPITAL where Sex=’F’ AND Age > 20;(v) To show all information about the patients whose names are having four characters only. (vi) To reduce Rs 200 from the charge of female patients who are in Cardiology department. (vii) To insert a new row in the above table with the following data :

11, ‘Rakesh’, 45, ‘ENT’, {08/08/08}, 1200, ‘M’ (viii) To remove the rows from the above table where age of the patient > 60.

Q4. Consider the following tables BOOKS. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).

Table : BOOKSB_Id Book_Name Author_Name Publisher Price Type QuantityC01 Fast Cook Lata Kapoor EPB 355 Cookery 5F01 The Tears William Hopkins First 650 Fiction 20T01 My C++ Brain & Brooke FPB 350 Text 10T02 C++ Brain A.W.Rossaine TDH 350 Text 15F02 Thuderbolts Anna Roberts First 750 Fiction 50

i). To list the names from books of Text type.ii). To display the names and price from books in ascending order of their price.iii). To increase the price of all books of EPB publishers by 50.iv). To display the Book_Name, Quantity and Price for all C++ books.v). Select max(price) from books;vi). Select count(DISTINCT Publishers) from books where Price >=400;vii). Select Book_Name, Author_Name from books where Publishers = ‘First’;viii). Select min(Price) from books where type = ‘Text’;

Page 15: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Q5. Consider the tables ITEMS & COMPANY. Write SQL commands for the statements (i) to (iv) and give the outputs for SQL queries (v) to (viii).

Table : ITEMSID PNAME PRICE MDATE QTYT001 Soap 12.00 11/03/2007 200T002 Paste 39.50 23/12/2006 55T003 Deodorant 125.00 12/06/2007 46T004 Hair Oil 28.75 25/09/2007 325T005 Cold Cream 66.00 09/10/2007 144T006 Tooth Brush 25.00 17/02/2006 455

Table : COMPANYID COMP CityT001 HLL MumbaiT008 Colgate DelhiT003 HLL MumbaiT004 Paras HaryanaT009 Ponds NoidaT006 Wipro Ahmedabad

i). To display PNAME, PRICE * QTY only for the city Mumbai.ii). To display product name, company name & price for those items which IDs are equal to the IDs of

company. iii). To delete the items produced before 2007. iv). To increase the quantity by 20 for soap and paste.v). SELECT COUNT(*) FROM ITEMS WHERE ITEMS.ID=COMPANY.ID;

vi). SELECT PNAME FROM ITEMS WHERE PRICE=SELECT MIN(PRICE) FROM ITEMS;vii). SELECT COUNT(*) FROM COMPANY WHERE COMP LIKE “P_ _ _ _”;

viii). SELECT PNAME FROM ITEMS WHERE QTY<100;

Short Answer Questions ( 2 marks)

Q1. State and verify Demorgan's Laws algebraically.Q2. State and algebraically verify Absorption Laws.Q3. State Distributive Laws. Write the dual of : X + X Y = X + YQ4. State any one form of Associative law and verify it using truth table.Q5. State the principle of duality in boolean algebra and give the dual of the following:

X.Y.Z + X.Y.Z + X.Y.ZQ6. Explain about tautology and fallacy.

SOP & POSVery Short Answer Questions ( 1 Mark)

Q1. Write the POS form of a Boolean function F, which is represented in a truth table as follows:U V W F0 0 0 10 0 1 00 1 0 10 1 1 01 0 0 11 0 1 01 1 0 11 1 1 1

Q2. Write the SOP form of a Boolean function G, which is represented in a truth table as follows:X Y Z G0 0 0 00 0 1 10 1 0 1

Page 16: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

U

V

0 1 1 01 0 0 01 0 1 11 1 0 11 1 1 0

Q3. Convert the following function into canonical SOP form.F( A , B, C, D ) = ( 1, 4, 6, 8, 11, 13)

Q4. Convert the following function into canonical SOP form.F( A , B, C, D ) = ( 0, 3, 7, 9, 10, 14)

Q5. Convert the following function to its equivalent SOP shorthand notation.F( A , B, C, D ) = ( 0, 3, 7, 9, 10, 14)

Q6. Convert the following function to its equivalent POS shorthand notation.F( A , B, C, D ) = ( 1, 4, 6, 8, 11, 13)

Karnaugh MapShort Answer Questions ( 3 marks)

Q1. Reduce the following Boolean Expression using K-Map: F( A, B, C, D ) = ( 0, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 14 )

Q2. Reduce the following Boolean Expression using K-Map: F( A, B, C, D ) = ( 0, 3, 5, 6, 7, 8, 11, 15 )

Q3. Reduce the following Boolean Expression using K-Map: F( A, B, C, D ) = ( 2, 3, 4, 5, 10, 11, 13, 14, 15 )

Q4. Reduce the following Boolean Expression using K-Map: F(A,B,C,D)=(0,1,2,4,5,6,8,10)Q5. reduce the following Boolean Expression using K-Map: F(A,B,C,D)=(0,1,4,5,7,10,13,15)

Basic Logic Gates

Short Answer Questions ( 2 marks)Q1. Write the equivalent Boolean Expression for the following Logic Circuit.

Q2. Write the equivalent Boolean Expression for the following Logic Circuit.

Q3. Draw the Logic Circuit Diagram for the following Boolean Expression :F = ( A . C ) + ( A . B ) + ( B . C )

Q4. Draw the diagram of digital circuit for F(A, B, C) = AB + BC + AC using NAND-to-NAND logic.

Q5. Draw the diagram of digital circuit for F(X, Y, Z) = (X + Y) (Y + Z) (X + Z) using NOR-to-NOR logic.

P

Q

Page 17: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Blo

ck

C

Blo

ck

A

Blo

ck

D

Blo

ck

B

Communication & Open Source ConceptsVery Short Answer Questions

Q1. What is a network?Q2. Mention the advantages of networking.Q3. Define server. Mention the types of servers.Q4. What is NIU? What does the MAC address refer to?Q5. What are the different types of switching techniques?Q6. What is a communication channel? Give examples of guided media & unguided media.Q7. Define the term Bandwidth. Give any one unit of Bandwidth.Q8. Expand : HTTP, FTP, TCP/IP, SLIP, PPP, NCP, GSM, TDMA, CDMA, WLL, PSTN.Q9. What are the different types of networks?Q10. What do you mean by network topology? What are the most popular topologies?Q11. What are the advantages of E-mail?Q12. What is WWW? What are the WWW attributes?Q13. What is web browser? Give any two examples of web browsers.Q14. Define the terms: Web site, Web page, Home page, Web portal.Q15. When do you prefer XML over HTML and why?Q16. Compare authorisation with authentication.Q17. What is Firewall? How firewall protects our network?Q18. What are cookies?Q19. How is a cracker different from a hacker? If someone has hacked your Website, to whom you lodge

the Complain?Q20. What is Cyberlaw?Q21. Expand : (i) FLOSS (ii) FSF (iii) OSI (iv) W3CQ22. What is a computer virus? Write the basic types of viruses.Q23. Define the terms : Trojan Horses, Worm, Spam.

Long Answer QuestionsQ1. Knowledge Supplement Organisation has set up its new centre at Mangalore for its office and web

based activities. It has 4 blocks of buildings as shown in the diagram below:

(a) Suggest a cable layout of connections between the blocks.(b) Suggest the most suitable place (i.e. block) to house the server of this organisation with a suitable

reason.(c) Suggest the placement of the following devices with justification

(i) Repeater (ii) Hub/Switch

Q2. Ravya Industries has set up its new center at Kaka Nagar for its office and web based activities. The company compound has 4 buildings as shown in the diagram below:

Centre to centre distances between various blocksBlack A to Block B 50 mBlock B to Block C 150 mBlock C to Block D 25 mBlock A to Block D 170 mBlock B to Block D 125 mBlock A to Block C 90 m

Number of ComputersBlack A 25Block B 50Block C 125Block D 10

Raj Buildin

g

FazzBuildin

g

Page 18: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

Building1 [40]

Building2 [45] Building3 [110]

Building4 [60]Building5 [70]

(a) Suggest a cable layout of connections between the buildings.(b) Suggest the most suitable place (i.e. building) to house the server of this organisation with a

suitable reason.(c) Suggest the placement of the following devices with justification:

(i) Internet Connecting Device/Modem(ii) Switch

(a) The organisation is planning to link its sale counter situated in various parts of the same city, which type of network out of LAN, MAN or WAN will be formed? Justify your answer.

Q3. Nootan Vidya Mandir in OOTY is setting up the network between its different wings. There are 4 wings named as SENIOR(S), MIDDLE(M), JUNIOR(J) and OFFICE(O).

(i) Suggest a suitable Topology for networking the computer of all wings. (ii) Name the wing where the server to be installed. Justify your answer. (iii) Suggest the placement of Hub/Switch in the network. (iv) Mention an economic technology to provide internet accessibility to all wings.

Q4. East and West Public Ltd. has decided to network all its offices spread in five buildings.

Harsh Buildi

ng

JazzBuildin

g

Centre to centre distances between various buildingsHarsh Building to Raj Building 50 mRaz Building to Fazz Building 60 mFazz Building to Jazz Building 25 mJazz Building to Harsh Building 170 mHarsh Building to Fazz Building 125 mRaj Building to Jazz Building 90 m

Number of ComputersHarsh Building 15Raj Building 150Fazz Building 15Jazz Bulding 25

Distance between the various wings are given below:Wing O to Wing S 100mWing O to Wing M 200mWing O to Wing J 400mWing S to Wing M 300mWing S to Wing J 100mWing J to Wing M 450m

Number of ComputersWing O 10Wing S 200Wing M 100Wing J 50

[ ] indicates the total no. of computers.

Page 19: Chapter Wise Questions C++ · Web viewDelhi T003 HLL Mumbai T004 Paras Haryana T009 Ponds Noida T006 Wipro Ahmedabad To display PNAME, PRICE * QTY only for the city Mumbai. To display

A

E

D

B C

The distances between buildings are given below:Between 1 & 2 20 Mts Between 3 & 5 70 MtsBetween 2 & 3 50 Mts Between 1 & 5 65 MtsBetween 3 & 4 120 Mts Between 2 & 5 50 MtsBetween 4 & 5 30 Mts Between 1 & 3 60 Mts

(i) Suggest cable layout(s) for connecting the buildings.(ii) Suggest the most suitable building to install the server of this organization with a suitable

reason, with justification.(iii) Suggest the placement of the following devices with justification?

(a) Hub/Switch(b) Repeater

(iv) The company also has another office in the same city but at a distant location about 25-30 kms away. How can link be established with this building? (i.e. suggest the transmission medium).

Q5. Standard Bank has set up its new center in India for its office and web based activities. It has five buildings as shown in the diagram below:

(a) Suggest a possible cable layout for connecting the buildings.(b) Suggest the most suitable place to install the server of this organization.(c) Suggest the placement of the following devices with justification.

(i.) Hub/Switch(ii.) Repeater

(d) The company wants to link its head office in ‘A’ building to its Office in Sydney(i) Which type of transmission medium is appropriate for such a link?(ii) What type of network this connection result into?

S.K.TiwariKV Sidhi

No of computersA 55B 180C 60D 55E 70

Distance between various buildingsA to B 50 MtsB to C 30 MtsC to D 30 MtsD to E 35 MtsE to C 40 MtsD to A 120 MtsD to B 45 MtsE to B 65 Mts