



Write the names of the correct header files, which must be included in the following C++ code to compile the code successfully:
void main () { char L[]="CS 2018"; int N=strlen(L); cout<<L[N-1]; }
Rewrite the following C++ Program after removing any/all syntactical error(s). Underline each correction done in the code:
Note: Assume all required header files are already included in the profram.
#define Area(L,B) = L*B structure Recta { int Length, Breadth; }; void main() { Recta R= [10, 15]; cout<<Area(Length.R, Breadth.R); }
Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.
void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; }
Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.
void Convert(float &X, int Y=2) { X=X.Y; Y=X+Y; cout<<X<<"*"<<Y<<endl; } void main() { float M=15, N=5; Convert(M,N) ; Convert(N) ; Convert(M) ; }
Observe the following C++ code and find the possible output(s) from
the option (i) to (iv) following it Also, write the minimum and maximum values that can possibly be assigned to the variable End.
Note:
-Assume all the required header files are already being included in the code.
-The function random(N) generated any possible integer between 0 amd M-1 (both values included)
void main() { randomize(); int a[] = {10,10,30,40,50,60,70,80}; int Start = random(2) +1; int End = Start + random(4); for (int I-Start; I<=End, I++) cout<<A[I]<<"$"; }
(1) 10$20$30$ | (ii) 20$30$40$50$60$ |
(iii) 30$40$50$60$ | (iv) 40$50$60$70$ |
Given the following class Test and assuming all necessary header file(s) included, answer the questions that follow the code:
class Test { int Marks; char TName[201]; public; Test(int M) //Function 1 { Marks = M; } Test(char S[]) //Function 2 { strocpy(TName, S); } Test(char S[], int M) //Function 3 { Marks = M; strcpy(TName, S); } Test(Test &T) //Function 4 { Marks = T.Marks+10; strcpy(TName, T.TName); } }; void main() { Test T1 (10); //Statement I Test T2 (70); //Statement II Test T3 (30, "PEACTICAL"); //Statement }
(i) Which of the Statement(S) out of (I), (II), (III), (IV) is/are incorrect for object(s) of the class Test?
(ii) What is Function 4 known as ? Write the Statement IV, that would execute Function 4.
Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.
class Point { int X,Y; public: Point(int I=10, int J=20) //Function 1 { X=J; Y=I; } void Show() //Function 2 { cout<<"Points are"<<X<<"&"<<Y<<endl; } ~Point() //Function 3 { cout<<"Points Erased"<<endl; } }; void main() { Point P(5); P.Show(); }
(i) For the class Point, what is Function 3 known as ? When is it executed ?
(ii) What is the output of the above code, on execution ?
Explain Polymorphism in context of Object Oriented Programming.
Also give a supporting example in C++.
Write the definition of a class GRAPH in C++ with following description:
Private Members
– XUnit // integer
– YUnit // integer
– Type // char array of size 20
– AssignType() /* Member function to assign value of Type based upon XUnit and YUnit as follows: */
Condition | Type |
XUnit = 0 or YUnit = 0 | None |
XUnit is more than YUnit | Bar |
XUnit is less than or equal to YUnit | Line |
Public Members
- InXY( ) /* Function to allow user to enter values of XUnit and YUnit and hen invoke AssignType() to assign value of Type*/
- OutXY() //Function to ddisplay XUnit, Yunit and Type
Answer the questions (i) to (iv) based on the following:
class Ground { int Rooms; protected: void Put(); public: void Get(); }; class Middle : private Ground { int Labs; public: void Tak(); void Give(); }; class Top : public Middle { int Roof; public: void In(); void Out(); }; void main() { Top T; }
(i) Which type of Inheritance out of the following is illustrated in the above example ?
– Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
(ii) Write the names of all the members, which are directly accessible by the member function Give() of class Middle.
(iii) write the names of all the members, which are directly accessible by the member function Out() of class Top.
(iv) Write the names of all the members, which are directly accessible by the object T of class Top declared in the main() function.
Consider the following class HeadQuarter
class HeadQuarter { int Code; char Des[20]; protected: char Address[40]; public: void Get() {cin>>Code;gets(Des);gets(Address);} void Put() {cout<<Code<<Des<<Address<<endl;} };
Write a code in C++ to protectedly derive another class FrontOffice From the base class HeadQuarter with following members.
Data Members
Location of type character of size 10
Budget of type double
Member Functions
A constructor function to assign budget as 100000
Assign() to allow user to enter Location and Budget
Display() to display Location and Budget
Write a user-defined function NoTwoThree(int Arr[], int N) in C++, which should display the value of all such elements and their corresponding locations in the array Arr (i.e. the array index), which are not multiples of 2 or 3. N represents the total number of elements in the array Arr, to be checked.
Example: If the array Arr contains
0 1 2 3 4
25 | 8 | 12 | 49 | 9 |
Then the function should display the output as:
25 at location 0
49 at location 3
Write a user-defined function ReArrange(int Arr[], int N) in C++, which should swap the contents of the first half locations of the array Arr with the contents of the second half locations. N (which is an even integer) represents the total number of elements in the array Arr.
Example :
If the array Arr contains the following elements (for N=6)
0 1 2 3 4 5
12 | 5 | 7 | 23 | 8 | 10 |
Then the function should rearrange the array to become:
0 1 2 3 4 5
23 | 8 | 10 | 12 | 5 | 7 |
NOTE:
- DO NOT DISPLAY the Changed Array contents.
- Do not use any other array to transfer the contents of array Arr.
Write definition for a function XOXO(char M[4][4]) in C++, which replaces every occurrence of an X with an O in array, and vice versa.
For example:
ORIGINAL ARRAY M | |||
X | X | O | X |
O | X | O | O |
O | O | X | X |
X | X | O | O |
CHANGED ARRAY M | |||
O | O | X | O |
X | O | X | X |
X | X | O | O |
O | O | X | X |
NOTE:
- DO NOT DISPLAY the Changed Array contents.
- Do not use any other array to transfer the ontents of array M.
Write definition for a function ColSwap(int A[4][4]) in C++, which swaps the contents of the first column with the contents of the third column.
For example:
ORIGINAL ARRAY A | |||
10 | 15 | 20 | 25 |
30 | 35 | 40 | 45 |
50 | 55 | 60 | 65 |
70 | 75 | 80 | 85 |
CHANGED ARRAY A | |||
20 | 15 | 10 | 25 |
40 | 35 | 30 | 45 |
60 | 55 | 50 | 65 |
80 | 75 | 70 | 85 |
NOTE:
- DO NOT DISPLAY the Changed Array contents.
- Do not use any other array to transfer the ontents of array A.
Let us assume P[20][10] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes, find the address of the elements P[10][5], if the address of the element P[5][2] is 25000.
Let us assume P[20][30] is a two-dimensional array, which is stored in the memory along the column with each of its elements occupying 2 bytes. Find the address of the element P[5][6], if the base address of array is 25000.
Write a user-defined function Pop(Book B[], int &T), which pops the details of a Book, from the stack of Book B, at the location T (representing the Top end of the stack), where every Book of the stack is represented by the following structure:
Struct Book { int Bno; char Bname[20]; };
For the following structure of Books in C++
Struct Book { int Bno; char Bname[20]; Book *Link; };
Given that the following declaration of class BookStack in C++ represents a dynamic stack of Books:
class BookStack { Book*Top; // inter with address of Topmost book of Stack public: BookStack() { Top = NULL; } void Push(); //Function to push a Book into the dyanmic Stack void Pop(); Function to pop a Book from the dynamic stack ~BookStack(); };
Evaluate the following Postfix expression, showing the stack contents:
250,45,9,/,5,+,20,*,-
Convert the following Infix expression to its equivalent Postfix expression , showing the stack contents for each step of converson:
A + B * C ^ D – E
A text file named MESSAGE.TXT contains some text. Another text file named SMS.TXT needs to be created such that it would store only the first 150 characters from the file MESSAGE.TXT.
Write a user-defined function LongToShort() in C++ that would perform the above task of creating SMS.TXT from the already existing file MESSAGE.TXT.
A text file named CONTENTS.TXT contains some text. Write a user-defined function LongWords() in C++ which display all such words of the file whose length is more than 9 alphabets. For example: if the file CONTENTS.TXT contains:
“Conditional statements of C++ programming language are if and switch”
Then the function LongWords() should display the output as:
Conditional
statements
programming
Write a user-defined function TotalPrice() in C++ to read each object of a binary file STOCK.DAT, and display the Name from all such records whose Price is above 150. Assume that the file STOCK.DAT is created with the help of objects of class Stock, which is defined below:
class Stock
{
char Name[20]; float Price;
public:
char* RName() { return Name; }
float RPrice() { return Price; }
};
A binary file DOCTORS.DAT contains records stored as objects of the following class:
class Doctor { int DNo; char Name[20]; float Fees; public; int *GetNo() { return DNo; } void Show() { cout<<Dno<<"*"<<Name<<"*"<<Fees<<endl; } };
Write definition for function Details(int N) in C+, which displays the details of the Doctor from the file DOCTORS.DAT, whose DNo matches with the parameter N passed to the function.
Find the output of the following C++ code considering that the binary file STOCK.DAT exist on the hard disk with the following 5 records for the class Stock containing Name and Price .
Name | Price |
Rice | 110 |
Wheet | 60 |
Cheese | 200 |
Pulses | 200 |
Sauce | 150 |
void main() { fstream File File.open("STOCK.DAT,ioc::binary|ios::in); Stock S; for (int I=1; I<=2; I++) { File.seekg((2*I-1)*sizeof(S)); File.read((char*)&S, sizeof(S)); cout<<"Read:"<<File.tellg()/sizeof(S)<<endl; } File.close(); }
Write SQL queries for (i) to (iv) and write outputs for SQL queries (v) to (viii), which are based on the table given below:
Table: TRAINS
TNO | TNAME | START | END |
---|---|---|---|
11096 | Ahimsa Express | Pune Junction | Ahmedabad Junction |
12015 | Ajmer Shatabdi | New Delhi | Ajmer Junction |
1651 | Pune Hbj Special | Pune Junction | Habibganj |
13005 | Amritsar Mail | Howrah Junction | Amritsar Junction |
12002 | Bhopal Shatabdi | New Delhi | Habibganj |
12417 | Prayag Raj Express | Allahabad Junction | New Delhi |
14673 | Shaheed Express | Jaynagar | Amritsar Junction |
12314 | Sealdah Rajdhani | New Delhi | Sealdah |
12498 | Shane Punjab | Amritsar Junction | New Delhi |
12451 | Shram Shakti Express | Kanpur Central | New Delhi |
12030 | Swarna Shatabdi | Amritsar Junction | New Delhi |
Table:PASSENGERS
PNR | TNO | PNAME | GENDER | AGE | TRAVELDATE |
---|---|---|---|---|---|
P001 | 13005 | R N AGRAWAL | MALE | 45 | 2018-12-25 |
P002 | 12015 | P TIWARY | MALE | 28 | 2018-11-10 |
P003 | 12015 | S TIWARY | FEMALE | 22 | 2018-11-10 |
P004 | 12030 | S K SAXENA | MALE | 42 | 2018-10-12 |
P005 | 12030 | S SAXENA | FEMALE | 35 | 2018-10-12 |
P006 | 12030 | P SAXENA | FEMALE | 12 | 2018-10-12 |
P007 | 13005 | N S SINGH | MALE | 52 | 2018-05-09 |
P008 | 12030 | J K SHARMA | MALE | 65 | 2018-05-09 |
P009 | 12030 | R SHARMA | FEMALE | 58 | 2018-05-09 |
(i) To display details of all Trains which Start from New Delhi.
(ii) To display the PNR, PNAME, GENDER and AGE of all Passengers whose AGE is below 50.
(iii) To display total number of MALE and FEMALE Passengers.
(iv) To display details of all Passengers travelling in Trains whose TNO is 12015.
(v) SELECT MAX (TRAVELDATE), MIN(TRAVELDATE) FROM PASSENGERS WHERE GENDER = ‘FEMALE’;
(vi) SELECT END, COUNT(*) FROM TRAINS GROUP BY END HAVING COUNT(*)>1;
(vii) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;
(viii) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P WHERE T.TNO=P.TNO AND AGE BETWEEN 50 AND 60;
Derive a Canonical POS expession for a Boolean function F, represented by the following truth table:
X | Y | Z | F(X,Y,Z) |
---|---|---|---|
0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 1 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 0 |
Reduce the following Boolean Expression to its simplest from using K-Map :
F(P, Q, R, S) = Σ(0,1,2,3,5,6,7,10,14,15)
Damodar Mohan has been informed that there had been a backdoor entry to his computer, which has provided access to his system through a malicious user/programs, allowing confidential and personal infornation to be subjected to theft. It happend because he clicked a link provided in one of the pop-ups from a website announcing him to be winner of prizes worth 1 million Dollars.
Which of the following has caused this out of the following?
(i) Virus
(ii) Worm
(iii) Trojan Horse
Also, mention, what he should do to prevent this infection.
Tarini Wadhawa is in India and she is interested in communicating with her uncle in Australia. She wants to show one of her own designed gadgets to him and also wants to demonstrate its working without physically going to Australia. Which protocol out of the following will be ideal for the same ?
(i) POP3
(ii) SMTP
(iii) VoI.P
(iv) HTTP
Write the expanded names for the following abbreviated terms used in Networking and Communication:
(i) MBPS
(ii) WAN
(iii) CDMA
(iv) WLL
Jonathan and Jonathan Training Institute is planning to set up its centre in Amritsar with four specialised blocks for Medicine, Management, Law courses alongwith an Admission block in separate buildings. The physical distances between these blocks and the number of computers to be installed in these blocks are given below. You as a network expert have to answer the queries as raised by their board of directors as given in (i)to (iv).
Admin Block to Management Block | 60 |
Admin Block to Medicine Block | 40 |
Admin Block to Law Block | 60 |
Management Block to Medicine Block | 50 |
Management Block to Law Block | 110 |
Law Block to Medicine Block | 40 |
Number of Computers installed at various locations are as follows:
Admin Block | 150 |
Management Block | 70 |
Medicine Block | 20 |
Law Block | 50 |
(i) Suggest the most suitable location to install the main server of this institution to get efficient connectivity.
(ii) Suggest the devices to be installed in each of these buildings for connecting computers installed within the building out of the following:
- Modem
- Switch
- Gateway
- Router
(iii) Suggest by drawing the best cable layout for effective network connectivity of the blocks having server with all the other blocks.
(iv) Suggest the most suitable wired medium for efficiently connecting each computer installled in every building out of the following network cables:
- Co-axial Cable
- Ethernet Cable
- Single Pair Telephone Cable