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

Similar documents
CLASS XII SECOND TERM EXAMINATION SUBJECT : COMPUTER SCIENCE SET A2 (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

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

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

Sample Paper Class XII SUBJECT : COMPUTER SCIENCE

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

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

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

Sample Paper, 2015 Subject: Computer Science Class 12 th

THE INDIAN COMMUNITY SCHOOL, KUWAIT

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

COMPUTER SCIENCE(083) SAMPLE QUESTION PAPER CLASS XII

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

Model Sample Paper 2015

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

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

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

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

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

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

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

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

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

KendriyaVidyalayaSangathan Kolkata Region

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

EAS 230 Fall 2002 Section B

DELHI PUBLIC SCHOOL BOKARO STEEL CITY ASSIGNMENT FOR THE SESSION

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

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

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

COMMON PRE-BOARD EXAMINATION COMPUTER SCIENCE

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

UNIT- 3 Introduction to C++

Lecture Data Structure Stack

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

CLASS-XI COMPUTER SCIENCE

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

KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION COMPUTER SCIENCE (083)

CS201 Latest Solved MCQs

HOLIDAYS HOMEWORK CLASS : XII. Subject : Computer Science

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

Object Oriented Pragramming (22316)

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)

DELHI PUBLIC SCHOOL BOKARO STEEL CITY

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

COMPUTER SCIENCE


Downloaded from Computer Science 083

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

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

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

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

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

Unit-V File operations

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

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

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

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

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

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


Downloaded from

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

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

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

UNIT-2 Stack & Queue

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

CLASS XII GUESS PAPER COMPUTER SCENCE (083)

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

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

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

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

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

Pointers, Dynamic Data, and Reference Types

A First Program - Greeting.cpp

KENDRIYA VIDYALAYA SANGATHAN TINSUKIA REGION PRE BOARD EXAMINATION SUBJECT COMPUTER SCIENCE

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

Queue: Queue Representation: Basic Operations:

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

Downloaded from

Computer Science 302 Spring 2018 Practice Examination for the Second Examination,

Short Notes of CS201

6.096 Introduction to C++ January (IAP) 2009

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

CS201 - Introduction to Programming Glossary By

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Ch - 7. Data File Handling

KENDRIYA VIDYALAYA SANGATHAN GUWAHATI REGION क य व लय स गठन, ग व ह ट स भ ग I-PRE BOARD EXAMINATION ( -ब ड पर )

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

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

Chapte t r r 9

Question Bank Class XII Subject : Computer Science

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS

AISSCE COMMON MODEL EXAMINATION Subject Computer Science [083] Time Allotted: 3 Hours Maximum Marks: 70

DISK FILE PROGRAM. ios. ofstream

The C++ Language. Arizona State University 1

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

QUESTION BANK SUB: COMPUTER SCIENCE(083)

Object Oriented Programming In C++

Transcription:

CLASS XII SECOND TERM EXAMINATION 2017-2018 SUBJECT : COMPUTER SCIENCE SET A1(SOLUTIONS) TIME ALLOWED : 3 HRS. MAX. MARKS:70 General Instructions : This paper consists of questions. There are 8 printed pages Attempt all questions neatly and in order. Q1a) 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 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) 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) 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 insert an element in circular queue containing integer values. Also declare class cqueue. (3) Ans. class cqueue int a[20];

int front, rear, max; public: queue( ) front=rear=-1; max=19; void add( ); void del( ); void display( ); int isfull( ); int isempty( ); ; int queue: :isfull( ) if((front= =rear+1) (front= =0) &&(rear= =max))) return 1; return 0; void queue: :add( ) if(isfull( )) cout<< \n queue overflow!! ; int temp; cin>>temp; if(isempty( )) front = rear = 0; if(rear= =max) rear=0; rear++; a[rear]=temp; 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. ( TRUE && FALSE ) ( ( ( ( ( ( ( && ( ( && ( ( TRUE TRUE TRUE FALSE TRUE FALSE && TRUE FALSE &&

7. 8. 9. 10. 11. 12. 13.! ( FALSE TRUE ) ) (! (! ( (! ( (! ( (! ( (! End Expression of TRUE FALSE && TRUE FALSE && TRUE FALSE && FALSE TRUE FALSE && FALSE TRUE FALSE && FALSE TRUE TRUE FALSE && FALSE TRUE TRUE FALSE && FALSE TRUE! Q4a) 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 count and display the number of lines in the file, FILE.TXT, starting with an upper case vowel. (2) Example. If content of FILE.TXT is On Monday, August 21 st 2017 all of North America will be treated with an eclipse of the sun. Anyone within the path of totality can see one of the nature s most awe-inspiring sights a total solar eclipse.

The program should give the output as: Number of lines : 1 Ans. #include <fstream.h> # include <string.h> void main() ofstream fout ( FILE.TXT ); char str [ 80 ]; int count=0; fin.getline( str, 80 ); while ( fin ) if ((str[0]== A ) (str[0]== E ) (str[0]== I ) (str[0]== O ) (str[0]== U )) puts(str); Count++; fin.getline( str, 80 ); cout<<count; 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 Q5a) 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 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) 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