KENDRIYA VIDYALAYA IIT CAMPUS CHENNAI 6 COMPUTER SCIENCE Half Yearly Time: Hrs M.M:70 1. a. Explain the difference between entry controlled loop and exit controlled loop with the help of an example. b. Write the header file required for the following pre-defined functions: 1 (i). ceil() (ii). delay() c. Rewrite the following after correcting the syntactical error(s). Underline the corrections: void main() { int max = 5; int a[max],i; a[max]={1,,,,5; for(i=0;i<max;i++) { if(a[i]%==0) { a[i]=pow(a[i],); a[i]=a[i]*; d. Write the output of the following: int a=10; void calc(int i,int &j) { a%5==0? a+=: a+=; i+=j; j+=a; void main() { int a=0,b=10; calc(a,b); cout<<a<<':'<<b<<endl; calc(b,a); cout<<::a<<':'<<b<<endl; calc(b,::a); cout<<b<<':'<<::a; e. Write the output of the following: #include<ctype.h> void main() 1 P a g e
{ char str[]="happy New Year 01"; for(int i=0;str[i]!='\0';i++) { if(i%==0) if(isupper(str[i])) str[i]=str[i]+1; str[i]='@'; if(islower(str[i])) str[i]=str[i+1]; str[i]='*'; cout<<str; f. Chose the correct alternative from the options (i)- (iv). Justify your answer #include<stdlib.h> #define Getval (N) void main( ) { randomize( ); int num= random()+; for( int I= num ; I<=num+ ;I++) cout<<getval(i)<< @ ; Options: ((N% = =0)? N+1:N+) a) @5@7@ b) 7@7@9@ c) 7@9@9@ d) 7@9@11@. a. Differentiate between private and protected members using example? b. Answer (i) & (ii) after going through the following class: class Interview { int month; Interview(int y){month=y; //function 1 Interview(Interview &t) ; //function ; (i). Write a C++ statement such that it calls function 1. (ii). Write the complete definition of function. P a g e
c. Define a class Bank to represent the bank account of a customer with the following specification Private Members: - Name of type character array(string) - Account_no of type long - Type_of_account ( S for Saving Account, C for current Account) of type char - Balance of type float Public Members: A constructor to initialize data members as follows - Name NULL - Account_no 100001 - Type_of_account S - Balance 1000 A function NewAccount() to input the values of the data members Name, Account_no, Type_of_account and Balance with following two conditions Minimum Balance for Current account is Rs.000 Minimum Balance for Saving account is Rs.1000 A function Deposit() to deposit money and update the Balance amount. A function Withdrawal() to withdraw money. Money can be withdrawn if minimum balance is as >=1000 for Saving account and >=000 for Current account. A function Display() which displays the contents of all the data members for a account. d. Answer (i) to (iv) based on the following code: class Teacher { char TNo[5],TName[0],Dept[10]; int Workload; protected: float Salary; vaoid AssignSal(float); Teacher(); void TEntry(); void TDisplay(); ; class Student { char Admno[10],SName[0],Stream[10]; protected: int Attendance, TotMarks; P a g e
Student(); void SEntry(); void SDisplay(); ; class School: public Student, public Teacher { char SCode[10],SchName[0]; School(); void SchEntry(); void SchDisplay(); ; (i).which type of inheritance is depicted in the above example? (ii).identify the member function(s) that cannot be called directly from the objects of class School from the following: TEntry(), TDisplay(), SchEntry() (iii).write name of all the member(s) accessible from member functions of class School. (iv).if class School was derived privately from class Teacher and privately from class Student, then name the member function(s) that could be accessed through objects of class School.. a. Write a function mergesort( int[],int[],int[],int,int,int&); in C++ which merges two Arrays A[] and B[] in a separate Array C[] in ascending order. Given that array A and B are in descending order. b. Write a function in C++ which accepts a D array of integers and its size as arguments and it interchanges the elements of both the diagonals. E.g. if the array elements are will be 1 5 6 9 8 7 1 5 6 7 8 9 then after diagonal interchange the array c. An array Arr[15][0] is stored in the memory along the row with each element occupying bytes. Find out the base address and address of the element Arr[][], if the element Arr[5][] is stored at the address 1500. d. Write the function Insert(int,char[]) and Delete() to insert and delete a note from a dynamically allocated Queue. Where the node is of following type: struct Customer { int CNo; P a g e
char CName[0]; Customer *Link; ; e. Evaluate the following postfix notation: 15 + / 7 + *. a. Observe the program segment given below carefully, and answer that follows: class PracFile 1 { int Pracno; char PracName[0]; int TimeTaken; int Marks; void EnterPrac(); //to get input void ShowPrac(); //to display details int RTime(){return TimeTaken; //to return TimeTaken void AssignMarks(int M){Marks=M; //to assign Marks ; void AllocateMarks() { fstream File("Marks.Dat",ios::binary ios::in::ios::out); PracFile p; int record=0; while(file.read((char*)&p,sizeof(p))) { if(p.rtime()>50) p.assignmarks(0); p.assignmarks(10); ; //statement 1 ; //statement record++; File.close(); If function AllocateMarks() is supposed to allocate marks for records in the file Marks.Dat, based on their value of the member TimeTaken. Write C++ statements for the statement1 and statement, where statement1 is required to position the file write pointer to an appropriate place in the file and statement is to perform the write operation with the modified record. b. Write a C++ program to print the lines starting with the word The from STORY.TXT. c. Write a C++ function to modify a record based on MNo passed to the function as argument from the binary file members.dat containing the records of following type: class Members 5 P a g e
{ int MNo; char MName[0],City[0]; int retmno(){return MNo; void display(); void input(); void modify(); ; 5. a. Explain primary key with the help of an example. b. Consider the following tables SUBJECT and TEACHER and write SQL queries for (i) to (iv) and the output of (V) to (viii) Table: SUBJECT Code Title Marks_Theory Marks_Prac 01 English 100 0 01 Maths 100 0 08 Computer Sc. 70 0 0 Physics 70 0 0 Chemistry 70 0 Table: TEACHER TCode Name Sub_Code 1 P. Jain 01 R. Nagpal 01 Supatra 01 Shabnam 08 5 Rashika 0 6 Vidushi 01 7 Yash 0 (i) To display the names of all the subjects for which practical marks are 0. (ii) To display the total number of teachers in each subject separately. (iii) To display the names of all the teachers in the ascending order of the Sub_Code. (iv) To display each subject s details along with Total_Marks in each subject from the table SUBJECT. (Total_Marks = Marks_Theory + Marks_Practical). (v) SELECT DISTINCT Marks_Theory from SUBJECT; (vi) SELECT TCode, Name from Teacher where Sub_Code like 0% ; (vii) SELECT count(*) FROM TEACHER WHERE NAME NOT LIKE '%a%'; (viii) Select UPPER(title) from subject where marks_theory=100; 6. a. State and prove demorgan s law. b. Write the POS expression of the following truth table: X Y Z Output F 0 0 0 0 6 P a g e 6 1
0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 c. Draw AND, OR and NOT gate using NAND Gate only. d. Reduce the following using K-Map: ( 5,6,7,8,9,1,1,1,15) 7. a. What do mean by Cyber Law? 1 b. What do mean by server side scripting? Give example. 1 c. Explain the difference between a bridge and a router? d. What is cookies? 1 e. What is PAN? 1 f. East and West Public Ltd has decided to network all its offices spread in five building as shown below: The distance between various buildings is as follows: Building 1 to Building 0Mts Building to Building 5 70Mts Building to Building 50Mts Building 1 to Building 5 65Mts Building to Building 10Mts Building to Building 5 50Mts Building to Building 5 0Mts Number of Computers in each building: Building 1 0 Building 5 Building 110 Building 60 Building 5 70 (i) Suggest a cable layout for connecting all the buildings together. (ii) Suggest the most suitable building to install the server of the organization with a suitable reason. (iii) Building is used for many critical operations. It is tries that PC gets maximum possible bandwidth. Which network device is/should be used for this? (iv) The organization also has another office in same city but at a distant location about5-0 Km away. How can link be established with building 1. (suggest the transmission media). 7 P a g e