SlideShare una empresa de Scribd logo
1 de 27
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

Más contenido relacionado

La actualidad más candente

A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to RAngshuman Saha
 
Structured data type
Structured data typeStructured data type
Structured data typeOmkar Majukar
 
Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Poonam Chopra
 
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasionsLuka 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 HaskellMichel Rijnders
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
 
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flowMohammed 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 181Mahmoud 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 arrayMajidHamidAli
 

La actualidad más candente (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
 

Destacado

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ÓGICAGerson Ames
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query OptimizationAnju 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 Examshishamrizvi
 

Destacado (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 a Qno 3 (a)

Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guideThalaAjith33
 
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 ProblemsSunil Yadav
 
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.pdfdhavalbl38
 
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.pdfrushabhshah600
 
Computer science ms
Computer science msComputer science ms
Computer science msB 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
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functionsSwarup Boro
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFTvikram mahendra
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsemGopi Saiteja
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptadityavarte
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.pptAqeelAbbas94
 

Similar a 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
 

Más de 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 algorithmsPraveen M Jigajinni
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructorsPraveen M Jigajinni
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programmingPraveen M Jigajinni
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with pythonPraveen M Jigajinni
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingPraveen M Jigajinni
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow chartsPraveen M Jigajinni
 

Más de 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
 

Último

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 

Último (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 

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.