xii cbse previous year question paper
Download
Skip this Video
Download Presentation
XII CBSE Previous Year Question Paper

Loading in 2 Seconds...

play fullscreen
1 / 27

XII CBSE Previous Year Question Paper - PowerPoint PPT Presentation


  • 80 Views
  • Uploaded on

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 3

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' XII CBSE Previous Year Question Paper' - silas-hanson


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
xii cbse previous year question paper
XII CBSE Previous Year Question Paper

QUESTION NO

3 (a)

3 Marks

slide2
(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 3

If the array is 1, 2, 3, 4, 5, 6

The resultant 2 D array is given

1 2 3 4 5 6

1 2 3 4 5 0

1 2 3 4 0 0

1 2 3 0 0 0

1 2 0 0 0 0

1 0 0 0 0 0

If the array is 1, 2, 3

The resultant 2 D array is given below

1 2 3

1 2 0

1 0 0

slide3
(a) const int R = 100, C = 100;

void Arrayconvert(int A1D[], int N)

{

int A2D[R][C]={0};

for(int I = 0; I

for (int J = 0; J

A2D[I][J] = A1D[J];

}

OR

slide4
(a)

const int R = 100, C = 100;

void Arrayconvert(int A1D[], int N)

{

int A2D[R][C];

for(int I = 0; I

for (int J = 0; J

if (J

A2D[I][J] = A1D[J];

else

A2D[I][J] = 0;

}

OR

slide5
OR

const int R = 100, C = 100;

void Arrayconvert(int A1D[], int N)

{

int A2D[R][C], I, J;

for(I = 0; I

for (J = 0; J

A2D[I][J] = 0;

for(I = 0; I

for (J = 0; J

A2D[I][J] = A1D[J];

}

OR

slide6
OR
  • Any other equivalent code
  • (1 mark for function header)
  • (1 mark for correct use of nested loops)
  • ( ½ mark for correctly assigning the values from 1D array to 2D array)
  • ( ½ mark for assigning 0 to the rest of the elements)
  • Note: Ignore declaration of the 2D array.
slide7
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 3

If the array is 1, 2, 3, 4, 5, 6

The resultant 2 D array is given below

1 0 0 0 0 0

1 2 0 0 0 0

1 2 3 0 0 0

1 2 3 4 0 0

1 2 3 4 5 0

1 2 3 4 5 6

If the array is 1, 2, 3

The resultant 2 D array is given below

1 0 0

1 2 0

1 2 3

slide8
(a) const int R = 100, C = 100;

void Arrayconvert(int A1D[ ], int N)

{

int A2D[R][C]={0};

for(int I = 0; 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)

slide9
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

slide10
(a) void Display(int NUM[],int N)

{

for(int i=0;i

{

if(NUM[i]%2==0)

NUM[i]=NUM[i]/2;

else

NUM[i]=2*NUM[i];

}

}

OR

slide11
OR

void Display(int NUM[],int N)

{

for(int i=0;i

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)

slide12
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

slide13
3. (a)

void Replace( int Arr[], int Size)

{

for(int i =0; i

if(Arr[i]%2 != 0 )

Arr[i] *= 3;

else

Arr[i] *= 2;

}

OR

slide14
void Replace( int Arr[], int Size)

{

for(int i =0; 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)

slide15
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 4

Example: 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

slide16
Ans:

void Rearrange( int Arr [], int Size)

{

for (int i = 0; i

{

int T = Arr[i];

Arr[i] = Arr[Size-1-i];

Arr[Size-1-i]=T;

}

}

OR

Any other correct equivalent function definition

slide17
(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 swapping

Deduct ½ Mark if reversed values are stored in another array

slide18
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, 10

then the function should rearrange the array as

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

slide19
Ans:

void Display (int NUM[ ], int N)

{

int T;

for (int I=0; I

{

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)

slide20
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 3

Note: Assume the following definition of structure Game

struct Game

{

long PNo; //Player Number

char PName [20] ;

long Points;

} ;

slide21
Sample content of the array (before sorting)

PNo PName Points

103 Ritika Kapur 3001

104 John Philip 2819

101 Razia Abbas 3451

105 Tarun Kumar 2971

Sample content of the array (after sorting)

PNo PName Points

101 Razia Abbas 3451

103 Ri tika Kapur 3001

105 Tarun Kumar 2971

104 John Philip 2819

slide22
Ans void SORTPOINTS(Game G[], int N)

{

Game Temp;

for (int I = 0; I

for (int J = 0; J

if(G[J].Points < G[J+l].Points)

{

Temp = G[J];

G[J] = G[J+l];

G[J+l] = Temp;

}

slide23
OR

Any 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 order

Deduct ½ Mark if only Points is swapped instead of the whole Structure

Deduct ½ Mark if Temp is not declared with correct data type

slide24
3. (a) Write a function SORTSCORE( ) in C++ to sort an array of structure Examinee in descending order of Score using Bubble Sort. 3

Note: Assume the following definition of structure Examinee

struct Examinee

{

long RollNo;

char Name [20] ;

float Score;

} ;

ad