CLASS XII SECOND TERM EXAMINATION SUBJECT : COMPUTER SCIENCE SET A2 (SOLUTIONS)

Similar documents
CLASS XII SECOND TERM EXAMINATION SUBJECT : COMPUTER SCIENCE SET A1(SOLUTIONS)

(d) Rewrite the following program after removing all the syntax error(s), if any. [2] include <iostream.h> void main ( )

PRINCE PUBLIC SCHOOL PRE-BOARD EXAMINATION ( ) SAMPLE PAPER-1 COMPUTER SCIENCE XII TIME ALLOWED: 3 HOURS

Sample Paper COMPUTER SCIENCE (Theory) Class-XII Time Allowed: 3hours Maximum Marks: 70

CLASS XII COMPUTER SCIENCE(083) TimeAllowed : 3 HrsMax Marks : 70

Sample Paper, 2015 Subject: Computer Science Class 12 th

void main() { int global=7 ; func( ::global,global) ; cout<<global<<, <<::global<< \n ; func(global,::global) ; cout<<global<<, <<::global<< \n ; }

void Add() { cin >> trainnumber; gets(trainname); } void display() { cout<<trainnumber <<":"<<TrainName<<end;

Sample Paper Class XII SUBJECT : COMPUTER SCIENCE

COMPUTER SCIENCE(083) SAMPLE QUESTION PAPER CLASS XII

Sample Paper 2013 SUB: COMPUTER SCIENCE GRADE XII TIME: 3 Hrs Marks: 70

THE INDIAN COMMUNITY SCHOOL, KUWAIT

JB Academy, Faizabad Half Yearly Examination Subject: Computer Science (083) Class XII

KUWAIT SAHODAYA EXAMINATION FIRST TERM SUBJECT : COMPUTER SCIENCE (083) : CLASS - XII SET - 3 Time : 3 Hours

CBSE GUESS PAPER. Roll No. Computer Sc. XII(083)/

KENDRIYA VIDYALAYA SANGATHAN (KOLKATA REGION) Second Pre Board Examination ( ) COMPUTER SCIENCE (Theory) Class-XII Marking Scheme

EAS 230 Fall 2002 Section B

CS201 Latest Solved MCQs

Model Sample Paper 2015

(a) Differentiate between a call by value and call by reference method.

SAMPLE PAPER. Class: XII SUBJECT COMPUTER SCIENCE. Time: 3 Hours MM: 70

Series SHC COMPUTER SCIENCE. Code No. 91. Roll No.

KendriyaVidyalayaSangathan Kolkata Region

Computer programs are associated to work with files as it helps in storing data & information permanently. File - itself a bunch of bytes stored on

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

DATA FILE HANDLING FILES. characters (ASCII Code) sequence of bytes, i.e. 0 s & 1 s

KENDRIYA VIDYALAYA SANGATHAN, COMPUTER SCIENCE (THEORY) I PRE-BOARD TIME 3 HRS CLASS XII M. Marks 70

DELHI PUBLIC SCHOOL BOKARO STEEL CITY ASSIGNMENT FOR THE SESSION

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

UNIT- 3 Introduction to C++

Object Oriented Pragramming (22316)

Guru Harkrishan Public School, Karol Bagh Pre Mock Class XII Sub: COMPUTER SCIENCE Allowed :3 hrs

DELHI PUBLIC SCHOOL BOKARO STEEL CITY

BHARATIYA VIDYA BHAVAN S V.M.PUBLIC SCHOOL, VADODARA. Class : XII SAMPLE PAPER Max Marks : 70

KE DRIYA VIDYALAYA SA GATHA,CHE AI REGIO. COMMO PRE-BOARD EXAMI ATIO COMPUTER SCIE CE CLASS- XII Time allowed : 3 hours Maximum Marks : 70

After going through this lesson, you would be able to: store data in a file. access data record by record from the file. move pointer within the file

(1)Given a binary file PHONE.DAT, containing records of the following structure type class Phonlist { char Name[20]; char Address[30]; char

Code No. 083 Time allowed: 3 hours Maximum Marks: 70 Instructions: (i) All questions are compulsory. (ii) Programming language: C++

A stream is infinite. File access methods. File I/O in C++ 4. File input/output David Keil CS II 2/03. The extractor and inserter form expressions

COMMON PRE-BOARD EXAMINATION COMPUTER SCIENCE

BRAIN INTERNATIONAL SCHOOL. Computer Science Assignment CLASS XII OCTOBER 2018 Chapter-7. Data File Handling in C++ Text Files

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

I Mid Semester May 2012 : Class XII : Computer Science Max Mark 50 : Time 2 Hrs. 1. a) What is macro in C++? Give example 2

Object Oriented Programming Using C++ UNIT-3 I/O Streams

SPLIT-UP SYLLABUS ----CHENNAI REGION COMPUTER SCIENCE (Code: 083) Class-XII Academic Session

HOLIDAYS HOMEWORK CLASS : XII. Subject : Computer Science

void display(){ cout << trainno.<< :>>Description<<endl; }; void main() {TRAIN T; Entry.(); Display.(); d) 410 e) i) south:east:south f) temttoe

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer:

Short Notes of CS201

C++ Binary File I/O. C++ file input and output are typically achieved by using an object of one of the following classes:

COMPUTER SCIENCE

Unit-V File operations

CS201 - Introduction to Programming Glossary By


Computer Science XII Important Concepts for CBSE Examination Questions


Come and join us at WebLyceum

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

CPE Summer 2015 Exam I (150 pts) June 18, 2015

SAMPLE PAPER-2015 CLASS-XII COMPUTER SCIENCE. Sample paper-i. Time allowed: 3 hours Maximum Marks: 70 Name : Roll No.:

Pointers, Dynamic Data, and Reference Types

(d) Observe the following C++ code very carefully and rewrite it after removing any/all syntactical errors: [2] Include < iostream.

C++_ MARKS 40 MIN

KENDRIYA VIDYALAYA SANGATHAN (CHANDIGARH REGION) MARKING SCHEME (Ist Pre Board )

Advanced File Operations. Review of Files. Declaration Opening Using Closing. CS SJAllan Chapter 12 2

Exam 3 Chapters 7 & 9

KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION FIRST COMMON PRE BOARD EXAMINATION CLASS:XII - (COMPUTER SCIENCE )

CLASS-XI COMPUTER SCIENCE

This chapter introduces the notion of namespace. We also describe how to manage input and output with C++ commands via the terminal or files.

KENDRIYA VIDYALAYA SANGATHAN. Regional Office Delhi Split-up Syllabus Session Subject:-Computer Science Subject Code:-083

Mock Test Paper-2. CBSE XII : Computer Science. Duration : 3hrs Max Marks : 70

A First Program - Greeting.cpp

BLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI. Unit Wise Marks

Downloaded from

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

SECTION A (15 MARKS) Answer ALL Questions. Each Question carries ONE Mark. 1 (a) Choose the correct answer: (10 Marks)

CLASS XII GUESS PAPER COMPUTER SCENCE (083)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

Chapte t r r 9

SAMPLE PAPER 2015 SUB - COMPUTER SCIENCE - (Theory) CLASS XII Time allowed: 3 hours Maximum marks: 70

4. BOOLEAN ALGEBRA 8 5. NETWORKING AND OPEN SOURCE SOFTWARE 10

COMPUTER SCIENCE Time allowed : 3hours] [Maximum Marks :70

KENDRIYA VIDYALAYA SANGATHAN TINSUKIA REGION PRE BOARD EXAMINATION SUBJECT COMPUTER SCIENCE

Downloaded from Computer Science 083

KE DRIYA VIDYALAYA SA GATHA, CHE AI REGIO. COMMO PRE-BOARD EXAMI ATIO COMPUTER SCIE CE (CLASS-XII) MARKI G SCHEME

SAMPLE QUESTION PAPER CLASS-XII, SESSION: SUBJECT: COMPUTER SCIENCE

What is Pointer? Pointer is a variable that holds a memory address, usually location of another variable.

KENDRIYA VIDYALAYA SANGATHAN BHUBANESWAR REGION SECOND PREBOARD EXAMINATION FOR CLASS XII SUBJECT: COMPUTER SCIENCE

For Teacher's Use Only Q No Total Q No Q No

CS2255 HOMEWORK #1 Fall 2012

Downloaded from

VuZs Team's Work. CS201 Spring Solved by vuzs Team with Reference Written by Administrator Wednesday, 19 May :52

KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION COMPUTER SCIENCE (083)

Question Bank Class XII Subject : Computer Science

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

COMMON PRE-BOARD EXAMINATION COMPUTER SCIENCE

File I/O Christian Schumacher, Info1 D-MAVT 2013

Object Oriented Programming In C++

Given the C++ declaration statement below, which of the following represents the value of exforsys? e) None of the above. 1K

Transcription:

CLASS XII SECOND TERM EXAMINATION 2017-2018 SUBJECT : COMPUTER SCIENCE SET A2 (SOLUTIONS) TIME ALLOWED : 3 HRS. MAX. MARKS:70 General Instructions : This paper consists of 6 questions. There are 7 printed pages Attempt all questions neatly and in order. Q1a) What do you understand by GSM? (1) Ans. GSM stands for Global System for Mobile Communications. GSM is a technique that uses narrowband TDMA (Time Division Multiple Access) to allow eight simultaneously calls on same radio frequency. b) What is the importance of URL in networking? (1) Ans. URL refers to Uniform Resource Locator. A URL stores the address of a web page on www. c) What is spam? (1) Ans Spam is flooding the Internet with many copies of the same message, in an attempt to force the message on people who would not otherwise choose to receive it. Most spam is commercial advertising, often for dubious products, getrich-quick schemes, or quasi-legal services. d) Which of the following unit measures the speed with which data can be transmitted from one node to another node of a network? Also, give the expansion of the suggested unit. (1) (i) Mbps (ii) KMph (iii) MGps Ans. (i) Mbps Mega bits per second. e) Granuda Consultants are setting up a secured network for their office campus at Faridabad for their day to day office and web-based activities. They are planning to have connectivity between 3 buildings and the head office situated in Kolkata. Answer the question (i) to (iv) after going through the building positions in the campus and other details, which are given below: (4)

Distance between various buildings: Building RAVI to Building JAMUNA Building RAVI to Building GANGA Building GANGA to Building JAMUNA Faridabad Campus to Head Office Number of Computers Building RAVI 25 Building JAMUNA 150 Building GANGA 51 Head Office 10 120 m 50 m 65 m 1460 km (i) Suggest the most suitable place (i.e., building) to house the server of this organization. Also give a reason to justify your suggested location. (ii) Suggest a cable layout of connections between the buildings inside the campus. (iii) Suggest the placement of the following devices with justification: (a) Switch (b) Repeater (iv) The organization is planning to provide a high speed link with its head office situated in the KOLKATA using a wired connection. Which of the following cable will be most suitable for this job? (a) Optical Fiber (b) Co-axial Cable (c) Ethernet Cable Ans.(i) Building Jamuna. As most computers are situated in this building and as per 80:20 rule of networking, maximum traffic should be local traffic. So server should be in building with maximum computers, i.e., building Jamuna. (ii)

(iii) (a) Switches are needed in every building as they help share bandwidth in every building. (b) Repeaters may be skipped as per above layout, (because distance is less than 100 m) however if building RAVI and building JAMUNA are directly connected, we can place a repeater there as the distance between these two buildings is more than 100 m. (iii) (a) Optical Fiber f) Anuradha is a web developer. She has designed a login form to input the login id and password of the user. She has to write a script to check whether the login id and the corresponding password as entered by the user are correct or not. What kind of script from the following will be most suitable for doing the same? (1) (i) JSP (ii) Client Side Script (iii) VB Script Ans. (i) JSP g) Which protocol helps us to transfer files to and from a remote computer? (1) Ans. FTP OR Telnet OR TCP Q2a) Define a class RESORT in C++ with following description: (4) Private members Rno //Data member to store Room No Name //Data member to store customer name Charges //Data member to store per day charges Days //Data member to store number of days of stay COMPUTE() //A function to calculate and return Amount as Days*Charges and if the value of Days*Charges is more than 11000 then as 1.02*Days*Charges Public Members Getinfo() //A function to enter the content Rno, Name,Charges and Days Dispinfo() //A function to display Rno, Name, Charges,Days and Amount (Amount to be displayed by calling function COMPUTE()) Ans : class RESORT { int Rno; char Name[20]; float Charges; int Days; float COMPUTE(); public:

void Getinfo(); void Dispinfo(); ; void RESORT::Getinfo() {cin>>rno; gets(name); cin>>charges; cin>>days; void RESORT::Dispinfo() {cout<<rno<< <<Name<< <<Charges<< <<Days<< COMPUTE()<<endl; float RESORT::COMPUTE() { float Amount = Charges*Days; if(amount>11000) Amount = 1.02*Days*Charges; return Amount; b) Explain the concept of constructor overloading with a suitable example in C++.(2) Ans: Overloaded constructors have the same name (name of the class) but different number of arguments. Depending upon the number and type of arguments passed, specific constructor is called. Since, there are multiple constructors present, argument to the constructor should also be passed while creating an object. c) Find the output of the following program: (3) #include<iostream.h> #include<conio.h> #include<ctype.h> #include<string.h> class Item { int Id ; char Name [20] ; float Price ; public : Item(int N=0, char M[]= "***", float P=100) { Id=N; strcpy(name, M); Price = P; void Rise(float P) {Price += P ; float RPrice() { return Price; void Show () { cout <<Id<< "#" <<Name<< "#" << Price<<endl ;

; void main () { Item I1, I2(5), I3(10, "Pen", 20) ; I3.Rise(I1.RPrice()) ; I2.Rise (I2.RPrice()) ; I1.Show() ; I2.Show() ; I3.Show(); Ans: 0#***#100 5#***#200 10#Pen#120 Q3a) What is the difference between #define and const? Explain with suitable example. (2) Ans: #define: It is a preprocessor directive in C++ for creating a Macro. Example: #define sqr(i) i*i const: It is an Access Modifier in C++ that assigns a constant (non modifiable) value to a variable. Any attempt in modifying the value assigned to such a variable is reported as an error by the compiler. Example: const float Pi = 3.14; b) Name the header files that shall be needed for the following code (1) void main( ) { char String[]= Hello ; cout<<setw(20)<<string; Ans: iostream.h iomanip.h c) Find the output of the following program: (3) #include<iostream.h> void main() { int X[ ] = {10,25,30,55,110; int *p = X; while ( *p < 110) { if ( *p%3!= 0 ) *p = *p + 1; *p = *p + 2; p++; for(int I = 4; I>=1 ; I--)

{ cout << X[I] << * ; if ( I%3 == 0) cout<<endl; cout<<x[0] * 3<<endl; Ans 110*56* 32*26*33 d) What is the difference between global & local variables? Explain with the help of an example. (2) Ans. A global variable is the one, which is declared outside all functions in the file & is available to all the functions & blocks defined in the file. A local variable is the one, which is declared inside a function or a block & is available to that function or block only. Example : #include<iostream.h> int A=2; int sum (int x, int y) { int z=x+y; return z; void main( ) { int B; B=A+sum(2,3); cout<<b; The variable A is global variable while x & y are local to function sum & B is local to function main. e) What will be the output of the following code: #include<iostream.h> (3) void Spill ( int A[ ], int N, int S) { for (int i=0; i<n; i++) if (i<s) A[i] *=i; A[i] /=i; void Display (int A[ ], int N) { for (int j=0; j<n; j++) if (j%2==0) cout<<a[j]<< % ;

cout<<a[j]<<endl; void main( ) { int Array[ ]= {30,40,50,20,10,5; Spill (Array,6,3); Display (Array,6); Ans 0%40 100%6 2%1 Q4a) Define the push( ), to insert nodes, and pop( ) to delete nodes for a linked implementation of a stack having the following structure of each node : (3+3) struct node { char name[30] ; int clss ; node * link; ; class stack { node * top; public : stack ( ) { top = NULL ; void push ( ); void pop ( ) ; ; Ans. void stack : : push( ) { node * nptr; nptr = new node; nptr link = NULL; cout << Enter name : ; gets(nptr name); cout << Enter the class : ; cin >> nptr clss ; if(top = = NULL) top = nptr; {nptr link = top; top = nptr;

void stack : : pop( ) { if(top = = NULL ) cout << Underflow!! { cout << Element being popped is \n ; cout << top name << ; << top clss<< endl; node * ptr; ptr = top; top = top link; delete ptr; b) Define member functions queinsert( ), to insert nodes and quedel( ), to delete nodes of a linked implemented queue where each node has the following structure: (3+3) struct node { char name[20]; int age; node * link; ; class queue { node * rear, * front ; public : queue() { front = NULL; rear = NULL; void queinsert( ); void quedel( ); ; Ans. void queue :: queinsert () { node * nptr; nptr = new node ; nptr -> link = NULL ; cout << enter the name and age for a new node ; gets ( nptr -> name); cin>>nptr -> age; if (rear == NULL ) { front = rear = nptr ; { rear -> link = nptr; rear = nptr ; void queue :: quedel ( )

{ node * nptr ; if ( front == NULL ) cout << underflow ; { ptr = front; if ( front == rear ) front = rear = NULL; front = front -> link; delete ptr; c) Write a member function to implement deletions in an array containing integer elements implemented as a circular queue. (3) Ans. int queue :: isempty ( ) { return ( front == -1); void queue :: quedel ( ) { int data ; if ( isempty ()) cout<< Underflow ; { data = q [front]; if ( front == rear ) front = rear = -1; if ( front == MAX ) front = 0; front ++ ; d) Evaluate the following postfix expression using a stack and show the contents of the stack after execution of each operation 5, 11, -, 6, 8,+, 12, *, /. (3) Ans. 5, 11, -, 6, 8,+, 12, *, /. Rules : Scanning from left to right (i) If operand Push (ii) If binary operator, pop twice if unary operator pop once (iii) Evaluate the result and push back STACK 1. 5 : operand : Push 5

2. 11 : operand : Push 5, 11 3. - : binary operator : pop # (empty stack) 4. Evaluate 5 11 = -6 : Push back - 6 5. 6 : operand : Push -6, 6 6. 8 : operand : Push -6, 6, 8 7. + : binary operator : pop twice - 6 8. Evaluate 6 + 8 = 14 ; push back -6, 14 9. 12 : operand : push -6, 14, 12 10. * : binary operator : pop back -6 11. Evaluate 14 * 2 = 168 : push back -6, 168 12. / : binary operator : pop twice # (stack empty) 13. Evaluate -6/168 = -1/28 : push back -1/28 14. End of Expression. Pop the result -1/28 = Result e) Convert the expression (TRUE && FALSE)! (FALSE TRUE) to postfix expression. Show the contents of the stack at every step. (3) Ans. (TRUE && FALSE)! (FALSE TRUE) ) Adding ) to the end of expression and inserting ( to the beginning of stack. Scanning from Left to Right S.No Symbol Stack Postfix Expression Y 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. ( TRUE && FALSE )! ( FALSE TRUE ) ( ( ( ( ( ( ( && ( ( && ( ( (! (! ( (! ( (! ( (! ( (! TRUE TRUE TRUE FALSE TRUE FALSE && TRUE FALSE && TRUE FALSE && TRUE FALSE && TRUE FALSE && FALSE TRUE FALSE && FALSE TRUE FALSE && FALSE TRUE TRUE FALSE && FALSE TRUE

13. ) End of Expression TRUE FALSE && FALSE TRUE! Q5a) Answer the questions (i) to (iv) based on the following: class ITEM { int Id; char IName[20]; protected: float Qty; public: ITEM(); void Enter(); void View(); ; class TRADER { int DCode; protected: char Manager[20]; public: TRADER(); void Enter(); void View(); ; class SALEPOINT : public ITEM, private TRADER { char Name[20],Location[20]; public : SALEPOINT(); void EnterAll(); void ViewAll(); ; i) Which type of Inheritance out of the following is illustrated in the above example? ii) Write the names of all the data members, which are directly accessible from the member functions of class SALEPOINT. iii) Write the names of all the member functions, which are directly accessible by an object of class SALEPOINT iv) What will be the order of execution of the constructors, when an object of class SALEPOINT is declared? Ans i) Multiple Inheritance ii) Name, Location, Manager, Qty iii) EnterAll(), ViewAll(), Enter(), View() iv) (i) ITEM() (ii) TRADER() (iii) SALEPOINT()

b) Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekp ( ) and seekg ( ) functions for performing the required task. (1) # include <fstream.h> class Item { int Ino; char Item[20]; public: void Search (int); // Function to search and display the content of void modify (int); // a particular record no. // Function to modify the content of a particular record no. ; void Item :: Search (intrecno) { fstream File; File. Open ( STOCK.DAT, ios :: binary ios :: in); // Statement 1 File.read ((char*) this, sizeof(item)); cout<<ino<< = = << Item <<endl; File.close ( ); void Item :: Modify (intrecno) { fstream File; File.open ( STOCK.DAT, ios :: binary ios :: out); cout>>ino; cin.getline(item, 20); // Statement 2 File.write ((char*)this, sizeof(item)); File.close ( ); Ans. File.seekg ((RecNo 1 ) * sizeof (Item); Statement 1 File.seekp ((RecNo 1 ) * sizeof (Item)) ; Statement 2 c) Write a program to read a text file FILE.TXT and then create another file REVERSE.TXT which contains every line of FILE.TXT in the reverse order. (2) Eg. If content of FILE.TXT is Hello how are you? Bye leaving now. REVERSE.TXT should have?uoy era woholleh.won gnivaeleyb Ans. #include <fstream.h> # include <string.h> void main ( ) { ofstream fout ( REVERSE.TXT );

ifstream fin ( FILE.TXT ); char str [ 80 ]; fin.getline( str, 80 ); while ( fin ) { int len = strlen ( str ) ; char temp; for ( int i = 0 ; i<len / 2 ; i ++ ) { temp = str [ i ] str [ i ] = str [ len 1 i ]; str [ len 1 i ] = temp; str [ len ] = \ 0 ; fout<<str<<endl ; fin.getline( str, 80 ); fin.close ( ); fout.close ( ); d) Given a binary file SPORTS.DAT, containing records of the following structure type: struct Sports { char Event[20]; char Participant[10][30]; ; Write a function in C++ that would read contents from the file SPORTS.DAT and creates a file named ATHELETIC.DAT copying only those records from SPORTS.DAT where the event name is Athletics. (3) Ans : void SPORT() { fstream IS,OA; Sports S; IS.open( SPORTS.DAT,ios::binary ios::in); OA.open( ATHLETIC.DAT,ios::binary ios::out); while(is.read((char*) &S,sizeof(S))) { if(strcmp(s.event, Athletics )==0) OA.write((char *)&S,sizeof(S)); IS.close(); OA.close(); e) The array A[20][10] is stored in the memory with each element requiring one byte of storage if the base address of A is Co. Determine Co if the location of A[10][15] is 2000, when the array is stored in Row major form. (3) Ans. Total rows M = 20

Total Columns N = 10 W (size in bytes of each element) = 2 Row major form Add (A[ I ] [ J ]) = Base Address + w ( ( I 0 ) N + ( J 0 ) ) Add (A[ 10 ] [ 15 ]) = C 0 + 1 ( ( 10 0 ) 10 + ( 15 0 ) ) 2000 = C 0 + 1 (100 + 15) 2000 = C 0 + 115 C 0 = 2000 115 = 1885 Base Address of array A = 1885 Q6a) Write definition for a function void Primes (int A[], int N), which assigns N number of prime integers to the N number of locations of the array A. For example if N is passed as 5, then the array should store. (3) 2 3 5 7 11 Ans : void Primes(int a[],int n) { int num = 2; int i=0; if (n==1) a[i]=2; { while (i < n) { int nofac=0; for (int j=2;j<=num/2;j++) if (num%j == 0) nofac++; if (nofac == 0) { a[i]=num; i++; num++; b) What do you understand by memory leak? Explain briefly. (2) Ans. If the objects, that are allocated memory dynamically, are not deleted, the memory block remains occupied even at the end of the program. Such memory blocks are known as orphaned memory blocks. These orphaned memory blocks when increase in number, brings an adverse effect on the system. This situation is known as memory leak. c) Write definition for function void SnakesLadders (int A[4] [4]) which assigns natural numbers to the cells of the 2D array of order 4X4, exactly like the snake

and ladders game boars, starting from bottom left corner of the board, as follows: (3) 16 15 14 13 9 10 11 12 8 7 6 5 1 2 3 4 Ans: void SnakesLadders(int a[4][4]) { int num=1; for (int i=3;i>=0;i--) { if (i%2==1) for (int j=0;j<4;j++) {a[i][j]=num; num++; for (int j=3;j>=0;j--) {a[i][j]=num; num++; d) Find the output of the following (Assume all header files are included): (2) # include <iostream.h> #include<ctype.h> void main () { char STR [ ] = "HLY 2017" ; char *P = STR; while (*P!= '\0') { if (isdigit (*P)) *P +=2; if (isalpha(*p)) *P = *(P+1); *P = '*' ; P++; cout << STR << endl;

Ans : LY *4239