Top Banner
XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks
27

XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

Jan 03, 2016

Download

Documents

Osborn Barrett
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

XII CBSE Previous Year Question

Paper

QUESTION NO 3 (a)

3 Marks

Page 2: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

(a) Write a function in C++ which accepts an integer array and its size as arguments / parameters and assign the elements into a two dimensional array of integers in the following format D 2006 3If the array is 1, 2, 3, 4, 5, 6The resultant 2 D array is given1 2 3 4 5 6 1 2 3 4 5 0 1 2 3 4 0 0 1 2 3 0 0 01 2 0 0 0 01 0 0 0 0 0

If the array is 1, 2, 3 The resultant 2 D array is given below1 2 31 2 01 0 0

Page 3: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

(a) const int R = 100, C = 100;void Arrayconvert(int A1D[], int N){int A2D[R][C]={0};for(int I = 0; I<N; I++)for (int J = 0; J <N-I; J++)A2D[I][J] = A1D[J];}

OR

Page 4: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

(a)const int R = 100, C = 100;void Arrayconvert(int A1D[], int N){int A2D[R][C];for(int I = 0; I<N; I++)for (int J = 0; J <N; J++)if (J<N-I)A2D[I][J] = A1D[J];elseA2D[I][J] = 0;}

OR

Page 5: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

ORconst int R = 100, C = 100;void Arrayconvert(int A1D[], int N){int A2D[R][C], I, J;for(I = 0; I<N; I++)for (J = 0; J <N; J++)A2D[I][J] = 0;for(I = 0; I<N; I++)for (J = 0; J <N-I; J++)A2D[I][J] = A1D[J];}

OR

Page 6: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.
Page 7: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function in C++ which accepts an integer array and its size as arguments/ parameters and assign the elements into a two dimensional array of integers in the following format : OD 2006 3If the array is 1, 2, 3, 4, 5, 6The resultant 2 D array is given below1 0 0 0 0 01 2 0 0 0 01 2 3 0 0 0 1 2 3 4 0 01 2 3 4 5 01 2 3 4 5 6

If the array is 1, 2, 3The resultant 2 D array is given below1 0 01 2 01 2 3

Page 8: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

(a) const int R = 100, C = 100;void Arrayconvert(int A1D[ ], int N){int A2D[R][C]={0};for(int I = 0; I<N; I++)for (int J = 0; J <=I; J++)A2D[I][J] = A1D[J];}( 1 mark for proper function header )( 1 mark for proper use of loops)( 1 mark for proper assignment of values)

Page 9: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function in C++ which accepts an integer array and its size as arguments and replaces elements having even values with its half and elements having odd values with twice its value. Outside Delhi 2007 4

Example : if an array of five elements initially contains the elements as,

3, 4, 5, 16, 9

then the function should rearrange the content of the array as,

6, 2, 10, 8, 18

Page 10: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

(a) void Display(int NUM[],int N){for(int i=0;i<N;i=i+1){if(NUM[i]%2==0)NUM[i]=NUM[i]/2;elseNUM[i]=2*NUM[i];}}

OR

Page 11: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

ORvoid Display(int NUM[],int N){for(int i=0;i<N;i=i+1)NUM[i]=(NUM[i]%2!=0)?2*NUM[i]:NUM[i]/2;}

(1 Mark for correct Function Header with proper Arguments)(1 Mark for correct loop)(1 Mark for checking Even / Odd values)(1 Mark for replacing array elements with proper values)

Page 12: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function in C++ which accepts an integer array and its size as arguments and replaces elements having odd values with thrice its value and elements having even values with twice its value. D 2007 4

Example : if an array of five elements initially contains the elements as

3, 4, 5, 16, 9

then the function should rearrange the content of the array as

9, 8, 15, 32, 27

Page 13: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) void Replace( int Arr[], int Size){for(int i =0; i<Size; i++)if(Arr[i]%2 != 0 )Arr[i] *= 3;elseArr[i] *= 2;}

OR

Page 14: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

void Replace( int Arr[], int Size){for(int i =0; i<Size; i++)Arr[i]%2 ? Arr[i] *= 2 : Arr[i] *= 3;}

(1 Mark for correct Function Header with proper Arguments)

(1 Mark for correct loop)

(1 Mark for checking Even / Odd values)

(1 Mark for replacing with proper values)

Page 15: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function in C++, which accepts an integer array and its size as parameters and rearranges the array in reverse.

Delhi 2008 4Example: if an array of nine elements initially contains the elements as

4, 2, 5, 1, 6, 7, 8, 12, 10

then the function should rearrange the array as

10, 12, 8, 7, 6, 1, 5, 2, 4

Page 16: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

Ans:void Rearrange( int Arr [], int Size){for (int i = 0; i<Size/2; i++){int T = Arr[i];Arr[i] = Arr[Size-1-i];Arr[Size-1-i]=T;}}ORAny other correct equivalent function definition

Page 17: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

(1 Mark for correct Function Header with proper Arguments)(1 Mark for correct loop)(2 Marks for swapping the values correctly)

Note:

Deduct ½ Mark if loop runs till Size instead of Size/2 for swappingDeduct ½ Mark if reversed values are stored in another array

Page 18: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function in C++, which accepts an integer array and its size as arguments and swaps the elements of every even location with its following odd location.

OUTSIDE DELHI 2008 4

Example: if an array of nine elements initially contains the elements as

2, 4, 1, 6, 5, 7, 9, 23, 10then the function should rearrange the array as

4, 2, 6, 1, 7, 5, 23, 9, 10

Page 19: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

Ans:void Display (int NUM[ ], int N){int T;for (int I=0; I<N–l; I+=2){T=N[I] ;N[I]=N[I+1] ;N[I+1] = T ;}}(1 Mark tor correct Function Header with proper Arguments)(1 Mark for correct loop)(2 Marks for swapping values correctly with / without a temporary variable)

Page 20: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function SORTPOINTS( ) in C++ to sort an array of structure Game in escending order of Points using Bubble Sort.

Delhi 2009 3Note: Assume the following definition of structure Gamestruct Game{long PNo; //Player Numberchar PName [20] ;long Points;} ;

Page 21: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

Sample content of the array (before sorting)

PNo PName Points103 Ritika Kapur 3001104 John Philip 2819101 Razia Abbas 3451105 Tarun Kumar 2971

Sample content of the array (after sorting)

PNo PName Points101 Razia Abbas 3451103 Ri tika Kapur 3001105 Tarun Kumar 2971104 John Philip 2819

Page 22: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

Ans void SORTPOINTS(Game G[], int N){Game Temp;for (int I = 0; I<N-l; I++)for (int J = 0; J<N-I-l; J++)if(G[J].Points < G[J+l].Points){Temp = G[J];G[J] = G[J+l];G[J+l] = Temp;}

Page 23: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

ORAny other correct equivalent function definition( ½ Mark for correct Function Header)( ½ Mark for each correct loop)( 1 Mark for correct comparison of adjacent elements)( ½ Mark for swapping the values correctly)Note:Deduct ½ Mark if sorted in ascending order instead of descending orderDeduct ½ Mark if only Points is swapped instead of the whole StructureDeduct ½ Mark if Temp is not declared with correct data type

Page 24: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

3. (a) Write a function SORTSCORE( ) in C++ to sort an array of structure Examinee in descending order of Score using Bubble Sort. 3Note: Assume the following definition of structure Examinee

struct Examinee{long RollNo;char Name [20] ;float Score;} ;

Page 25: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.
Page 26: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.
Page 27: XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks.

THANK YOU