SlideShare a Scribd company logo
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
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
(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
(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];
else
A2D[I][J] = 0;
}
OR
OR
const 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
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
(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)
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
(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;
else
NUM[i]=2*NUM[i];
}
}
OR
OR
void 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)
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
3. (a)
void Replace( int Arr[], int Size)
{
for(int i =0; i<Size; i++)
if(Arr[i]%2 != 0 )
Arr[i] *= 3;
else
Arr[i] *= 2;
}
OR
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)
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
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;
}
}
OR
Any other correct equivalent function
definition
(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
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
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)
3. (a) Write a function SORTPOINTS( ) in C++
to sort an array of structure Game in
escending order of Points using Bubble Sort.
Delhi
20093
Note: Assume the following definition of
structure Game
struct Game
{
long PNo; //Player Number
char PName [20] ;
long Points;
} ;
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
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;
}
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
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;
} ;
THANK
YOU

More Related Content

What's hot

Arrays in C
Arrays in CArrays in C
Arrays in C
Kamruddin Nur
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to R
Angshuman Saha
 
Structured data type
Structured data typeStructured data type
Structured data type
Omkar Majukar
 
C arrays
C arraysC arrays
Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Computer Science Sample Paper 2015
Computer Science Sample Paper 2015
Poonam Chopra
 
K map
K mapK map
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasions
Luka Jacobowitz
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng웅식 전
 
Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)
Denpong Soodphakdee
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
Michel Rijnders
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
YOGESH SINGH
 
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flow
Mohammed Sikander
 
Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1IIUM
 
Directed Acyclic Graph
Directed Acyclic Graph Directed Acyclic Graph
Directed Acyclic Graph
AJAL A J
 
The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181
Mahmoud Samir Fayed
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Palak Sanghani
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
JAINAM KAPADIYA
 
Data structure array
Data structure  arrayData structure  array
Data structure array
MajidHamidAli
 

What's hot (20)

Arrays in C
Arrays in CArrays in C
Arrays in C
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to R
 
Chapter2
Chapter2Chapter2
Chapter2
 
Structured data type
Structured data typeStructured data type
Structured data type
 
C arrays
C arraysC arrays
C arrays
 
Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Computer Science Sample Paper 2015
Computer Science Sample Paper 2015
 
K map
K mapK map
K map
 
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasions
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flow
 
Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1
 
Directed Acyclic Graph
Directed Acyclic Graph Directed Acyclic Graph
Directed Acyclic Graph
 
The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
Data structure array
Data structure  arrayData structure  array
Data structure array
 

Viewers also liked

6 Inheritance
6 Inheritance6 Inheritance
6 Inheritance
Praveen M Jigajinni
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
Praveen M Jigajinni
 
RESULTADOS JEFE DE GESTIÓN PEDAGÓGICA
RESULTADOS JEFE DE GESTIÓN PEDAGÓGICARESULTADOS JEFE DE GESTIÓN PEDAGÓGICA
RESULTADOS JEFE DE GESTIÓN PEDAGÓGICA
Gerson Ames
 
13 Boolean Algebra
13 Boolean Algebra13 Boolean Algebra
13 Boolean Algebra
Praveen M Jigajinni
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
Anju Garg
 
3 Function Overloading
3 Function Overloading3 Function Overloading
3 Function Overloading
Praveen M Jigajinni
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)
Yuki Tamura
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
Ahmed Farag
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
hishamrizvi
 

Viewers also liked (11)

6 Inheritance
6 Inheritance6 Inheritance
6 Inheritance
 
12 SQL
12 SQL12 SQL
12 SQL
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
RESULTADOS JEFE DE GESTIÓN PEDAGÓGICA
RESULTADOS JEFE DE GESTIÓN PEDAGÓGICARESULTADOS JEFE DE GESTIÓN PEDAGÓGICA
RESULTADOS JEFE DE GESTIÓN PEDAGÓGICA
 
13 Boolean Algebra
13 Boolean Algebra13 Boolean Algebra
13 Boolean Algebra
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
 
3 Function Overloading
3 Function Overloading3 Function Overloading
3 Function Overloading
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 

Similar to Qno 3 (a)

2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
Education Front
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guide
ThalaAjith33
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
NehaJain919374
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Sunil Yadav
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
 
Arrays
ArraysArrays
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-arrayDeepak Singh
 
c++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfc++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdf
dhavalbl38
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
Computer science ms
Computer science msComputer science ms
Computer science ms
B Bhuvanesh
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
2DArrays.ppt
2DArrays.ppt2DArrays.ppt
2DArrays.ppt
Nooryaseen9
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
Swarup Boro
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
vrgokila
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
vikram mahendra
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
Gopi Saiteja
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.ppt
adityavarte
 
Array
ArrayArray
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
AqeelAbbas94
 

Similar to Qno 3 (a) (20)

2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guide
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 
Arrays
ArraysArrays
Arrays
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-array
 
c++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfc++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdf
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Computer science ms
Computer science msComputer science ms
Computer science ms
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
2DArrays.ppt
2DArrays.ppt2DArrays.ppt
2DArrays.ppt
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.ppt
 
Array
ArrayArray
Array
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
 

More from Praveen M Jigajinni

Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
Praveen M Jigajinni
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructors
Praveen M Jigajinni
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
Praveen M Jigajinni
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programming
Praveen M Jigajinni
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
Praveen M Jigajinni
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Unit 3 MongDB
Unit 3 MongDBUnit 3 MongDB
Unit 3 MongDB
Praveen M Jigajinni
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
Praveen M Jigajinni
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
Praveen M Jigajinni
 
Chapter 14 strings
Chapter 14 stringsChapter 14 strings
Chapter 14 strings
Praveen M Jigajinni
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
Praveen M Jigajinni
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
Praveen M Jigajinni
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
Praveen M Jigajinni
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with python
Praveen M Jigajinni
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinking
Praveen M Jigajinni
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
Chapter 5 boolean algebra
Chapter 5 boolean algebraChapter 5 boolean algebra
Chapter 5 boolean algebra
Praveen M Jigajinni
 
Chapter 4 number system
Chapter 4 number systemChapter 4 number system
Chapter 4 number system
Praveen M Jigajinni
 

More from Praveen M Jigajinni (20)

Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithms
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructors
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programming
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Unit 3 MongDB
Unit 3 MongDBUnit 3 MongDB
Unit 3 MongDB
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Chapter 14 strings
Chapter 14 stringsChapter 14 strings
Chapter 14 strings
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with python
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinking
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
 
Chapter 5 boolean algebra
Chapter 5 boolean algebraChapter 5 boolean algebra
Chapter 5 boolean algebra
 
Chapter 4 number system
Chapter 4 number systemChapter 4 number system
Chapter 4 number system
 

Recently uploaded

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

Qno 3 (a)

  • 1. XII CBSE Previous Year Question Paper QUESTION NO 3 (a) 3 Marks
  • 2. (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
  • 3. (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
  • 4. (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]; else A2D[I][J] = 0; } OR
  • 5. OR const 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
  • 6.
  • 7. 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
  • 8. (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)
  • 9. 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
  • 10. (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; else NUM[i]=2*NUM[i]; } } OR
  • 11. OR void 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)
  • 12. 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
  • 13. 3. (a) void Replace( int Arr[], int Size) { for(int i =0; i<Size; i++) if(Arr[i]%2 != 0 ) Arr[i] *= 3; else Arr[i] *= 2; } OR
  • 14. 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)
  • 15. 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
  • 16. 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; } } OR Any other correct equivalent function definition
  • 17. (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
  • 18. 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
  • 19. 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)
  • 20. 3. (a) Write a function SORTPOINTS( ) in C++ to sort an array of structure Game in escending order of Points using Bubble Sort. Delhi 20093 Note: Assume the following definition of structure Game struct Game { long PNo; //Player Number char PName [20] ; long Points; } ;
  • 21. 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
  • 22. 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; }
  • 23. 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
  • 24. 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; } ;
  • 25.
  • 26.