Professional Documents
Culture Documents
26/11/15
Max. Marks: 70
Time: 3 hrs
General Instructions:
This question paper consists of 9 printed pages.
All answers to be written in the answer sheet provided.
Programming Language to be used is C++.
I.
b. Observe the following C++ code and write the header files, which are essentially
required to run the program code.
void main()
{
char msg;
msg=getchar();
cout<<setw(5)<<tolower(msg);
}
c. Observe the following C++ code carefully and rewrite the same after removing
all the syntax error(s) . Ensure that you underline each correction.
(Assume that all the desired header files are already included.)
appear on the screen after execution of it. (Assume that all the desired header files
are already included.)
void decrypt(char *Str)
{
int C , L= strlen(Str);
for (C=0;C<=L-2;C++)
if(!isalnum(*(Str+C)))
*(Str+C)= *(Str+C-1);
else if(isdigit(*(Str+C)))
*(Str+C)= *(Str+C)+5;
else if(isupper(*(Str+ C)))
*(Str + C)=*(Str+ L-C-1);
else
*(Str+C)= *(Str + C);
*(Str+C+1)= *(Str+C+1);
}
void main()
{
char *secret="Vr@No3@BeST";
decrypt(secret);
puts("The code is");
puts(secret);
}
e.
Observe the following C++ code carefully and obtain the output, which will
appear on the screen after execution of it. (Assume that all the desired header files
are already included.)
int W = 3;
void calculus(int x, int &y, char *z)
{
W += x+y;
x = W+y;
y += x;
z = z+3;
cout<<x<<'*'<<y<<'\n'<<z<<'*'<<W<<endl;
}
void main()
{
int W = 2, b = 5;
char *txt="MoToR ShoW";
calculus(W,::W,txt);
cout<<*txt<<'*'<<W;
}
f. Based on the following C++ code, find out the expected correct output(s) from
Page 2 of 9
the options (i) to (iv). Justify your answer.(Assume that all the desired header files
are already included.)
void main()
{
char msg[] = "HY EXAMS";
int marks[]= {85,72,67,45,93};
randomize();
cout<<marks[random(3)]-5;
for(int i=0;i<4;i++)
cout<<msg[sizeof(long)+random(2)+1];
}
Options:i) 62MAMA
ii) 80XMAM
iii) 62EXAA
iv) 68MMMM
II. a.
b. Answer the questions (i) and (ii) after going through the following class:-
2
2
class Syllabus
{
char ChapterName[20];
int Marks;
public:
Syllabus(char *cname, int ma)
//Member Function 1
{
strcpy (Chapter,Data Structures);
Marks = 14;
cout<<Chapter Initialised;
}
~Syllabus( )
//Member Function 2
{
cout<<Chapter Over;
}
};
i) Write statements to invoke Function 1 implicitly and explicitly.
ii) What is Function 2 and when does it get invoked.
c. Define a class Technovanza in C++ with the following specification:
Data Members:
Scode to store School code
Cname to store name of Comptt
Page 3 of 9
void calc_net();
public:
void enter();
void display();
};
i) Which type of Inheritance is shown in the above example.
ii) Write the names of member functions, which can be directly accessed from
the objects of class temporary.
iii) Write the names of data members, which can be accessed from getdetails()
function of class permanent.
iv) What is the size of class temporary.
III. a.
Write a function shift() which accepts a 1-D array A[] ,search element S and its size
N as parameter. Search for a particular element and perform the following
operations:
i)
Remove all occurrences of the search element.
ii)
Shift the elements of the array to the right so that used space is available
at the left end.
b. An array CA[10][12] is stored in the memory along the column with each element
occupying 4 bytes. Find the address of the element CA[2][10] if element CA[2][3] is
stored at the address 4500.
c. Write a function unitmatrix() which accepts a 2-D array (square matrix) and its size
as parameters and checks if the matrix is a unit matrix or not.
(A unit matrix is a square matrix with 1s on the major diagonal and 0s elsewhere.)
d. Convert the following infix expression to postfix showing the stack status.
(U-V)+W/X^Y*(Z/H)
struct vehicle
{
int vehno;
char vehname[20];
char vehmake;
vehicle *link;
};
vehicle *front=NULL , *rear=NULL;
IV. a.
Observe the program given and fill the blanks marked as Statement 1 and 2 .
Page 5 of 9
class vaccine
{
int vaccno;
char vaccname[20];
float dosageamt;
public:
void getnewdetails(); // Function to accept new vaccine details.
void administer(); // Function to modify the details of particular vaccine no.
};
void vaccine::administer()
{
fstream f1;
f1.open(Medical.dat, ios::binary|ios::ate) ;
int vacn;
cout<<Enter vaccine no :;
cin>>vacn;
getnewdetails();
__________________________________________________; //Statement 1
__________________________________________________; //Statement 2
f1.close();
}
b. Write a function count() to count the number palindromes present in a text file
Story.txt. (Standard library functions can be used.)
Ex) "This is my mom and dad ." No of palindromes is 2
class Metal
{
char Mname[20];
char Mtype[20];
float Mprice;
public:
void getmetal();
void putmetal();
char *returntype()
{
return type;
}
}m1;
i) Write a function in C++ to read the objects of Metal from binary file Metal.dat
and display metal details, which are of corrosive type.
ii) Write a function to insert a new record after the 3rd record.
V. a. Differentiate between Primary Key and Alternate Key stating examples.
Page 6 of 9
RELATION : FURNITURE
No
C001
F005
T008
F002
T003
Itemname
White Lotus
Dolphin
Comfort Zone
Royal Tiger
Pink feather
Type
Double Bed
Baby Cot
Double Bed
Sofa
Baby Cot
DateofStock
23/02/02
20/01/02
12/01/02
13/12/01
04/02/02
Price
30000
700
25000
31000
1100
Discount
25
20
15
25
10
RELATION : ARRIVALS
No
Location
T008
Sharjah
C001
Dubai
F005
Dubai
Write SQL commands for questions i) to iv) and state o/p for questions v) to viii):i) To list itemname and type of items from furniture table in which DateofStock is
before 22/01/02 in descending order of itemname.
ii) To count the items whose price is > 25000 and item name starts with D.
iii) To display the type and the maximum price in each type.
iv) To list the itemname and location to where the item has to be delivered.
v) SELECT MIN(Discount) FROM FURNITURE;
vi) SELECT SUM(Price) FROM FURNITURE WHERE Type IN (Sofa,Baby
Cot);
vii) SELECT COUNT(DISTINCT Type) FROM FURNITURE;
viii) SELECT No , Itemname , Price FROM FURNITURE WHERE Price
BETWEEN 25000 AND 30000 .
VI. a.
Page 7 of 9
c. Write the SOP form of the function F(A,B,C) for the following truth table :A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
F(A,B,C)
1
0
0
1
1
0
1
0
d. Obtain the minimal form for the following Boolean expression using K-Map.
F(U,V,W,Z) = (0,2,3,4,5,6,8,10,11,12,13,14)
VII. a. State any 2 advantages of networking.
3
1
c.
60m
90m
115m
40m
45m
25m
***************
Page 9 of 9