Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C++ program:
_Cost, Price*Qty, float, Switch,
Address One, Delete, Number12, do
Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C++ program:
_Cost, Price*Qty, float, Switch,
Address One, Delete, Number12, do
Jayapriya has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.
void main() { float A,Number,Outcome; cin>>A>>Number; Outcome=pow(A,Number); cout<<Outcome<<endl; }
Rewrite the following C++ code after removing any/all syntactical errors with
each correction underlined.
Note: Assume all required header files are already being included in the program.
#define Equation(p,q) = p+2*q void main() { float A=3.2;B=4.1; C=Equation(A,B); cout<<'Output='<<C<<endl; }
Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.
typedef char STRING[80]; void MIXITNOW(STRING S) { int Size=strlen(S); for (int I=0;I<Size-1;I+=2) { char WS=S[I]; S[I]=S[I+1]; S[I+1]=WS; } for (I=1;I<Size;I+=2) if (S[I]>='M' && S[I]<='U') S[I]=’@’; } void main() { STRING Word="CRACKAJACK"; MIXITNOW(Word); cout<<Word<<endl; }
Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
class Stock { long int ID; float Rate; int Date; public: Stock(){ID=1001;Rate=200;Date=1;} void RegCode(long int I,float R) { ID=I; Rate=R; } void Change(int New,int DT) { Rate+=New; Date=DT; } void Show() { cout<<”Date :”<<Date<<endl; cout<<ID<<”#”<<Rate<<endl; } }; void main() { Stock A,B,C; A.RegCode(1024,150); B.RegCode(2015,300); B.Change(100,29); C.Change(20,20); A.Show(); B.Show(); C.Show(); }
Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable CHANGER.
Note:
– Assume all the required header files are already being included in the code.
– The function random(n) generates an integer between 0 and n-1
void main() { randomize(); int CHANGER; CHANGER=random(3); char CITY[][25]={”DELHI”,”MUMBAI”,”KOLKATA” ,”CHENNAI”}; for(int I=0;I<=CHANGER;I++) { for(int J=0;J<=I;J++) cout<<CITY[J]; cout<<endl; } }
(i) | (ii) |
---|---|
DELHI
DELHIMUMABAI DELHIMUMABAIKOLKATA |
DELHI
DELHIMUMABAI DELHIMUMABAIKOLKATA DELHIMUMABAIKOLKATACHENNAI |
(iii) | (iv) |
MUMABAI
MUMABAIKOLKATA MUMABAIKOLKATACHENNAI |
KOLKATA
KOLKATACHENNAI |
Differentiate between Constructor and Destructor functions giving suitable example using a class in C++. When does each of them execute?
Observe the following C++ code and answer the questions (i) and (ii). Assume all necessary files are included:
class FICTION { long FCode; char FTitle[20]; float FPrice; public: FICTION() //Member Function 1 { cout<<”Bought”<<endl; FCode=100;strcpy(FTitle,”Noname”);FPrice=50; } FICTION(int C,char T[],float P) //Member Function 2 { FCode=C; strcpy(FTitle,T); FPrice=P; } void Increase(float P) //Member Function 3 { FPrice+=P; } void Show() //Member Function 4 { cout<<FCode<<”:”<<FTitle<<”:”<<FPrice<<endl; } ~FICTION() //Member Function 5 { cout<<”Fiction removed!”<<end1; } }; void main() //Line 1 { //Line 2 FICTION F1,F2(101,”Dare”,75); //Line 3 for (int I=0;I<4;I++) //Line 4 { //Line 5 F1.Increase(20);F2.Increase(15); //Line 6 F1.Show();F2.Show(); //Line 7 } //Line 8 } //Line 9
(i) Which specific concept of object oriented programming out of the following is illustrated by Member Function 1 and Member Function 2 combined together?
– Data Encapsulation
– Data Hiding
- Polymorphism
– Inheritance
(ii) How many times the message ”Fiction removed!” will be displayed after executing the above C++ code? Out of Line 1 to Line 9, which line is responsible to display the message “Fiction removed!”?
Write the definition of a class METROPOLIS in C++ with following description: Private Members -Mcode //Data member for Code (an integer) -MName //Data member for Name (a string) -MPop //Data member for Population (a long int) -Area //Data member for Area Coverage (a float) -PopDens //Data member for Population Density (a float) -CalDen() //A member function to calculate //Density as PopDens/Area Public Members -Enter() //A function to allow user to enter values of //Mcode,MName,MPop,Area and call CalDen() //function -ViewALL()//A function to display all the data members //also display a message "Highly Populated Area" //if the Density is more than 12000
Answer the questions (i) to (iv) based on the following:
class PRODUCT { int Code; char Item[20]; protected: float Qty; public: PRODUCT(); void GetIn(); void Show(); }; class WHOLESALER { int WCode; protected: char Manager[20]; public: WHOLESALER(); void Enter(); void Display(); }; class SHOWROOM : public PRODUCT, private WHOLESALER { char Name[20],City[20]; public: SHOWROOM(); void Input(); void View(); };
(i) Which type of Inheritance out of the following is illustrated in the above example?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the
member functions of class SHOWROOM.
(iii) Write the names of all the member functions, which are directly accessible by an
object of class SHOWROOM.
(iv) What will be the order of execution of the constructors, when an object of class
SHOWROOM is declared?
Write the definition of a function FixPay(float Pay[], int N) in C++, which should
modify each element of the array Pay having N elements, as per the following
rules:
Existing Value of Pay | Pay to be changed to |
---|---|
If less than 100000 | Add 25% in the existing value |
If >=100000 and <20000 | Add 20% in the existing value |
If >=200000 | Add 15% in the existing value |
T[20][50] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 4 bytes, find the address of the element T[15][5], if the element T[10][8] is stored at the memory location 52000.
Write the definition of a member function INSERT() for a class QUEUE in C++, to insert an ITEM in a dynamically allocated Queue of items considering the following code is already written as a part of the program.
struct ITEM { int INO; char INAME[20]; ITEM *Link; }; class QUEUE { ITEM *R,*F; public: QUEUE(){R=NULL;F=NULL;} void INSERT(); void DELETE(); ~QUEUE(); };
Write definition for a function SHOWMID(int P[][5],int R,int C) in C++ to display the elements of middle row and middle column from a two dimensional array P having R number of rows and C number of columns.
For example, if the content of array is as follows:
115 | 112 | 116 | 101 | 125 |
103 | 101 | 121 | 102 | 101 |
185 | 109 | 109 | 160 | 172 |
The function should display the following as output :
103 101 121 102 101
116 121 109
Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
A/(B+C)*D-E
Write function definition for WORD4CHAR() in C++ to read the content of a text file FUN.TXT, and display all those words, which has four characters in it.
Example: If the content of the file fun.TXT is as follows:
When I was a small child, I used to play in the garden with my grand mom. Those days were amazingly funful and I remember all the moments of that time |
The function WORD4CHAR() should display the following:
When used play with days were that time |
Write a definition for function BUMPER( ) in C++ to read each object of a binary file GIFTS.DAT, find and display details of those gifts, which has remarks as “ÖN DISCOUNT”. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:
class GIFTS { int ID;char Gift[20],Remarks[20]; float Price; public: void Takeonstock() { cin>>ID;gets(Gift);gets(Remarks);cin>>Price; } void See() { cout<<ID<<":"<<Gift<<":"<<Price<<"":"<<Remarks<<endl; } char *GetRemarks(){return Remarks;} };
Find the output of the following C++ code considering that the binary file MEM.DAT exists on the hard disk with a data of 1000 members.
class MEMBER { int Mcode;char MName[20]; public: void Register();void Display(); }; void main() { fstream MFile; MFile.open("MEM.DAT",ios::binary|ios::in); MEMBER M; MFile.read((char*)&M, sizeof(M)); cout<<"Rec:"<<MFile.tellg()/sizeof(M)<<endl; MFile.read((char*)&M, sizeof(M)); MFile.read((char*)&M, sizeof(M)); cout<<"Rec:"<<MFile.tellg()/sizeof(M)<<endl; MFile.close(); }
Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in LIST ? Also, find the Degree and Cardinality of the LIST.
STUDENTS
NO | NAME |
---|---|
1 | Tara Mani |
2 | Jaya Sarkar |
3 | Tarini Trikha |
EVENTS
EVENTCODE | EVENTNAME |
---|---|
1002 | Programming |
1002 | IT Quiz |
LIST
NO | NAME | EVENTCODE | EVENTNAME |
---|---|---|---|
1 | Tara Mani | 1001 | Programming |
1 | Tara Mani | 1002 | IT Quiz |
2 | Jaya Sarkar | 1001 | Programming |
2 | Jaya Sarkar | 1002 | IT Quiz |
3 | Tarini Trikha | 1001 | Programming |
3 | Tarini Trikha | 1002 | IT Quiz |
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables
Table: VEHICLE
CODE | VTYPE | PERKM |
---|---|---|
101 | VOLVO BUS | 160 |
102 | AC DELUXE BUS | 150 |
103 | ORDINARY BUS | 90 |
105 | SUV | 40 |
104 | CAR | 20 |
Note:
– PERKM is Freight Charges per kilometer
– VTYPE is Vehicle Type
Table: TRAVEL
NO | NAME | TDATE | KM | CODE | NOP |
---|---|---|---|---|---|
101 | Janish Kin | 2015-11-13 | 200 | 101 | 32 |
103 | Vedika Sahai | 2016-04-21 | 100 | 103 | 45 |
105 | Tarun Ram | 2016-03-23 | 250 | 102 | 42 |
102 | John Fen | 2016-02-13 | 90 | 102 | 40 |
107 | Ahmed Khan | 2015-01-10 | 75 | 104 | 2 |
104 | Raveen | 2016-05-28 | 80 | 105 | 4 |
106 | Kripal Anya | 2016-02-06 | 200 | 101 | 25 |
Note:
– NO is Traveller Number
- KM is Kilometer travelled
– NOP is number of travellers travelled in vehicle
- TDATE is Travel Date
(i) To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.
(ii) To display the NAME of all the travellers from the table TRAVEL who are traveling by vehicle with code 101 or 102.
(iii) To display the NO and NAME of those travellers from the table TRAVEL who
travelled between ’2015-12-31′ and ’2015-04-01’.
(iv) To display all the details from table TRAVEL for the travellers, who have
travelled distance more than 100 KM in ascending order of NOP.
(v) SELECT COUNT(*),CODE FROM TRAVEL
GROUP BY CODE HAVING COUNT(*)>1;
(vi) SELECT DISTINCT CODE FROM TRAVEL;
(vii) SELECT A.CODE,NAME,VTYPE
FROM TRAVEL A,VEHICLE B
WHERE A.CODE=B.CODE AND KM<90;
(viii) SELECT NAME,KM*PERKM
FROM TRAVEL A,VEHICLE B
WHERE A.CODE=B.CODE AND A.CODE=’105’;
Verify the following using Boolean Laws.
A’+ B’.C = A’.B’.C’+ A’.B.C’+ A’.B.C + A’.B’.C+ A.B’.C
Write the Boolean Expression for the result of the Logic Circuit as shown below:
Derive a Canonical POS expression for a Boolean function F, represented by the following truth table:
P | Q | R | F(P,Q,R |
---|---|---|---|
0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 |
Reduce the following Boolean Expression to its simplest form using K-Map:
F(X,Y,Z,W)= (2,6,7,8,9,10,11,13,14,15)
Give two examples of PAN and LAN type of networks.
Which protocol helps us to browse through web pages using internet browsers? Name any one internet browser.
Write two advantages of 4G over 3G Mobile Telecommunication Technologies in terms of speed and services?
Write two characteristics of Web 2.0.
What is the basic difference between Trojan Horse and Computer Worm?
Categories the following under Client side and Server Side script category?
(i) VB Sript
(ii) ASP
(iii) JSP
(iv) Java Script
Uplifting Skills Hub India is a knowledge and skill community which has an aim to uplift the standard of knowledge and skills in the society. It is planning to setup its training centers in multiple towns and villages pan India with its head offices in the nearest cities. They have created a model of their network with a city, a town and 3 villages as follows. As a network consultant, you have to suggest the best network related solutions for their issues/problems raised in (i) to (iv), keeping in mind the distances between various locations and other given parameters.
Shortest distances between various locations:
VILLAGE 1 to B_TOWN | 2 KM |
VILLAGE 2 to B_TOWN | 1.0 KM |
VILLAGE 3 to B_TOWN | 1.5 KM |
VILLAGE 1 to VILLAGE 2 | 3.5 KM |
VILLAGE 1 to VILLAGE 3 | 4.5 KM |
VILLAGE 2 to VILLAGE 3 | 2.5 KM |
A_CITY Head Office to B_HUB | 25 Km |
Number of Computers installed at various locations are as follows:
B_TOWN | 120 |
VILLAGE 1 | 15 |
VILLAGE 2 | 10 |
VILLAGE 3 | 15 |
A_CITY OFFICE | 6 |
Note:
-In Villages, there are community centers, in which one room has been given as training center to this organization to install computers.
-The organization has got financial support from the government and top IT companies.
(i) Suggest the most appropriate location of the SERVER in the B_HUB (out of the 4 locations), to get the best and effective connectivity. Justify your answer.
(ii) Suggest the best wired medium and draw the cable layout (location to location) to efficiently connect various locations within the B_HUB.
(iii) Which hardware device will you suggest to connect all the computers within each location of B_HUB?
(iv) Which service/protocol will be most helpful to conduct live interactions of Experts from Head Office and people at all locations of B_HUB?