SlideShare a Scribd company logo
// C Program to shuffle a given Aay
#include
#include
#include
// A utility function to print an Aay
void printArray (int A[], int n)
{
int i;
for (i = 0; i < n; i++)
printf("%d ", A[i]);
printf(" ");
}
int* shuffle(int A[], int B[])
{
int n1 = 5;
int n2 = 2;
int i = 0, j = 0, k = 0;
int *C;
C = (int*)malloc(7 * sizeof(int));
// Merging starts
while (i < n1 && j < n2)
{
if (k%2 == 0)
{
C[k] = A[i];
i++;
k++;
}
else
{
C[k] = B[j];
k++;
j++;
}
}
/* elements in array 'A' are still remaining
where as the array 'B' is exhausted */
while (i < n1)
{
C[k] = A[i];
i++;
k++;
}
/* elements in array 'B' are still remaining
where as the array 'A' is exhausted */
while (j < n2)
{
C[k] = B[j];
k++;
j++;
}
return C;
}
int main()
{
int A[] = {1, 2, 3, 4, 5};
int B[] = {10, 20};
int n1 = 5;
int n2 = 2;
int nC = 7;
int *C;
C = (int*)malloc(7 * sizeof(int));
printf("Array A: ");
printArray(A, n1);
printf("Array B: ");
printArray(B, n2);
C = shuffle (A, B);
printf(" Shuffled: ");
printArray(C,nC);
return 0;
}
/*
output:
Array A: 1 2 3 4 5
Array B: 10 20
Shuffled: 1 10 2 20 3 4 5
*/
Solution
// C Program to shuffle a given Aay
#include
#include
#include
// A utility function to print an Aay
void printArray (int A[], int n)
{
int i;
for (i = 0; i < n; i++)
printf("%d ", A[i]);
printf(" ");
}
int* shuffle(int A[], int B[])
{
int n1 = 5;
int n2 = 2;
int i = 0, j = 0, k = 0;
int *C;
C = (int*)malloc(7 * sizeof(int));
// Merging starts
while (i < n1 && j < n2)
{
if (k%2 == 0)
{
C[k] = A[i];
i++;
k++;
}
else
{
C[k] = B[j];
k++;
j++;
}
}
/* elements in array 'A' are still remaining
where as the array 'B' is exhausted */
while (i < n1)
{
C[k] = A[i];
i++;
k++;
}
/* elements in array 'B' are still remaining
where as the array 'A' is exhausted */
while (j < n2)
{
C[k] = B[j];
k++;
j++;
}
return C;
}
int main()
{
int A[] = {1, 2, 3, 4, 5};
int B[] = {10, 20};
int n1 = 5;
int n2 = 2;
int nC = 7;
int *C;
C = (int*)malloc(7 * sizeof(int));
printf("Array A: ");
printArray(A, n1);
printf("Array B: ");
printArray(B, n2);
C = shuffle (A, B);
printf(" Shuffled: ");
printArray(C,nC);
return 0;
}
/*
output:
Array A: 1 2 3 4 5
Array B: 10 20
Shuffled: 1 10 2 20 3 4 5
*/

More Related Content

Similar to C Program to shuffle a given Aay#include stdio.h #include .pdf

C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
Saket Pathak
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
AkhilaaReddy
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
anujmkt
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
Rupendra Choudhary
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Salar Delavar Qashqai
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
kkkseld
 
Answers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxAnswers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxismailaboshatra
 
Answers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxAnswers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxismailaboshatra
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
Functions
FunctionsFunctions
Functions
Arpit Modh
 
using C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docxusing C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docx
slyndon
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 

Similar to C Program to shuffle a given Aay#include stdio.h #include .pdf (20)

Arrays
ArraysArrays
Arrays
 
week-3x
week-3xweek-3x
week-3x
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
 
week-21x
week-21xweek-21x
week-21x
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
Qno 1 (e)
 
Answers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxAnswers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docx
 
Answers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docxAnswers+of+C+sample+exam.docx
Answers+of+C+sample+exam.docx
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
Functions
FunctionsFunctions
Functions
 
using C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docxusing C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docx
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 

More from amaresh6333

a) It is given E is the event of getting 2. We can observe that 2 is.pdf
a) It is given E is the event of getting 2. We can observe that 2 is.pdfa) It is given E is the event of getting 2. We can observe that 2 is.pdf
a) It is given E is the event of getting 2. We can observe that 2 is.pdf
amaresh6333
 
4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf
4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf
4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf
amaresh6333
 
A special type of IP address is the limited broadcast address 255.25.pdf
A special type of IP address is the limited broadcast address 255.25.pdfA special type of IP address is the limited broadcast address 255.25.pdf
A special type of IP address is the limited broadcast address 255.25.pdf
amaresh6333
 
10 leading causes of death in the United States In the recent sta.pdf
10 leading causes of death in the United States In the recent sta.pdf10 leading causes of death in the United States In the recent sta.pdf
10 leading causes of death in the United States In the recent sta.pdf
amaresh6333
 
1.Router 1.It is a machine which aheads datagrams over the networks.pdf
1.Router 1.It is a machine which aheads datagrams over the networks.pdf1.Router 1.It is a machine which aheads datagrams over the networks.pdf
1.Router 1.It is a machine which aheads datagrams over the networks.pdf
amaresh6333
 
1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf
amaresh6333
 
Step1 Total pressure = partial pressure of Hydrog.pdf
                     Step1 Total pressure = partial pressure of Hydrog.pdf                     Step1 Total pressure = partial pressure of Hydrog.pdf
Step1 Total pressure = partial pressure of Hydrog.pdf
amaresh6333
 
I would say very many elements exista as monoatom.pdf
                     I would say very many elements exista as monoatom.pdf                     I would say very many elements exista as monoatom.pdf
I would say very many elements exista as monoatom.pdf
amaresh6333
 
E is simply hexane...no polarity at all...nothing.pdf
                     E is simply hexane...no polarity at all...nothing.pdf                     E is simply hexane...no polarity at all...nothing.pdf
E is simply hexane...no polarity at all...nothing.pdf
amaresh6333
 
Ferroxyl contains the chemical compound Potassium.pdf
                     Ferroxyl contains the chemical compound Potassium.pdf                     Ferroxyl contains the chemical compound Potassium.pdf
Ferroxyl contains the chemical compound Potassium.pdf
amaresh6333
 
There are two different types of mechanisms. Ther.pdf
                     There are two different types of mechanisms. Ther.pdf                     There are two different types of mechanisms. Ther.pdf
There are two different types of mechanisms. Ther.pdf
amaresh6333
 
What must be true about a set of data when its standard deviation is.pdf
What must be true about a set of data when its standard deviation is.pdfWhat must be true about a set of data when its standard deviation is.pdf
What must be true about a set of data when its standard deviation is.pdf
amaresh6333
 
When one drives from sea level to trailhead in high Sierras, altitud.pdf
When one drives from sea level to trailhead in high Sierras, altitud.pdfWhen one drives from sea level to trailhead in high Sierras, altitud.pdf
When one drives from sea level to trailhead in high Sierras, altitud.pdf
amaresh6333
 
the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf
                     the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf                     the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf
the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf
amaresh6333
 
The important thing here is to understand the Standard Electrode Pot.pdf
The important thing here is to understand the Standard Electrode Pot.pdfThe important thing here is to understand the Standard Electrode Pot.pdf
The important thing here is to understand the Standard Electrode Pot.pdf
amaresh6333
 
The pathway would be overactive.The GTPase activity of the alpha s.pdf
The pathway would be overactive.The GTPase activity of the alpha s.pdfThe pathway would be overactive.The GTPase activity of the alpha s.pdf
The pathway would be overactive.The GTPase activity of the alpha s.pdf
amaresh6333
 
The metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdf
The metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdfThe metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdf
The metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdf
amaresh6333
 
The electron carriers that feed into the ETC are NADH and FADH2.NA.pdf
The electron carriers that feed into the ETC are NADH and FADH2.NA.pdfThe electron carriers that feed into the ETC are NADH and FADH2.NA.pdf
The electron carriers that feed into the ETC are NADH and FADH2.NA.pdf
amaresh6333
 
The developmental potential, or potency of a cell, describes the ran.pdf
The developmental potential, or potency of a cell, describes the ran.pdfThe developmental potential, or potency of a cell, describes the ran.pdf
The developmental potential, or potency of a cell, describes the ran.pdf
amaresh6333
 
Tested on linux,ubuntu#include stdlib.h #include systypes..pdf
Tested on linux,ubuntu#include stdlib.h #include systypes..pdfTested on linux,ubuntu#include stdlib.h #include systypes..pdf
Tested on linux,ubuntu#include stdlib.h #include systypes..pdf
amaresh6333
 

More from amaresh6333 (20)

a) It is given E is the event of getting 2. We can observe that 2 is.pdf
a) It is given E is the event of getting 2. We can observe that 2 is.pdfa) It is given E is the event of getting 2. We can observe that 2 is.pdf
a) It is given E is the event of getting 2. We can observe that 2 is.pdf
 
4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf
4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf
4.1 (a) SoftwoodsThese generally come from the gymnosperm trees wh.pdf
 
A special type of IP address is the limited broadcast address 255.25.pdf
A special type of IP address is the limited broadcast address 255.25.pdfA special type of IP address is the limited broadcast address 255.25.pdf
A special type of IP address is the limited broadcast address 255.25.pdf
 
10 leading causes of death in the United States In the recent sta.pdf
10 leading causes of death in the United States In the recent sta.pdf10 leading causes of death in the United States In the recent sta.pdf
10 leading causes of death in the United States In the recent sta.pdf
 
1.Router 1.It is a machine which aheads datagrams over the networks.pdf
1.Router 1.It is a machine which aheads datagrams over the networks.pdf1.Router 1.It is a machine which aheads datagrams over the networks.pdf
1.Router 1.It is a machine which aheads datagrams over the networks.pdf
 
1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf
 
Step1 Total pressure = partial pressure of Hydrog.pdf
                     Step1 Total pressure = partial pressure of Hydrog.pdf                     Step1 Total pressure = partial pressure of Hydrog.pdf
Step1 Total pressure = partial pressure of Hydrog.pdf
 
I would say very many elements exista as monoatom.pdf
                     I would say very many elements exista as monoatom.pdf                     I would say very many elements exista as monoatom.pdf
I would say very many elements exista as monoatom.pdf
 
E is simply hexane...no polarity at all...nothing.pdf
                     E is simply hexane...no polarity at all...nothing.pdf                     E is simply hexane...no polarity at all...nothing.pdf
E is simply hexane...no polarity at all...nothing.pdf
 
Ferroxyl contains the chemical compound Potassium.pdf
                     Ferroxyl contains the chemical compound Potassium.pdf                     Ferroxyl contains the chemical compound Potassium.pdf
Ferroxyl contains the chemical compound Potassium.pdf
 
There are two different types of mechanisms. Ther.pdf
                     There are two different types of mechanisms. Ther.pdf                     There are two different types of mechanisms. Ther.pdf
There are two different types of mechanisms. Ther.pdf
 
What must be true about a set of data when its standard deviation is.pdf
What must be true about a set of data when its standard deviation is.pdfWhat must be true about a set of data when its standard deviation is.pdf
What must be true about a set of data when its standard deviation is.pdf
 
When one drives from sea level to trailhead in high Sierras, altitud.pdf
When one drives from sea level to trailhead in high Sierras, altitud.pdfWhen one drives from sea level to trailhead in high Sierras, altitud.pdf
When one drives from sea level to trailhead in high Sierras, altitud.pdf
 
the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf
                     the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf                     the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf
the reaction as follows- 14N7 + 0n1 -- 4He2 + 1.pdf
 
The important thing here is to understand the Standard Electrode Pot.pdf
The important thing here is to understand the Standard Electrode Pot.pdfThe important thing here is to understand the Standard Electrode Pot.pdf
The important thing here is to understand the Standard Electrode Pot.pdf
 
The pathway would be overactive.The GTPase activity of the alpha s.pdf
The pathway would be overactive.The GTPase activity of the alpha s.pdfThe pathway would be overactive.The GTPase activity of the alpha s.pdf
The pathway would be overactive.The GTPase activity of the alpha s.pdf
 
The metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdf
The metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdfThe metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdf
The metal ion is Pb2+.The white precipitate PbCl2 is insoluble in .pdf
 
The electron carriers that feed into the ETC are NADH and FADH2.NA.pdf
The electron carriers that feed into the ETC are NADH and FADH2.NA.pdfThe electron carriers that feed into the ETC are NADH and FADH2.NA.pdf
The electron carriers that feed into the ETC are NADH and FADH2.NA.pdf
 
The developmental potential, or potency of a cell, describes the ran.pdf
The developmental potential, or potency of a cell, describes the ran.pdfThe developmental potential, or potency of a cell, describes the ran.pdf
The developmental potential, or potency of a cell, describes the ran.pdf
 
Tested on linux,ubuntu#include stdlib.h #include systypes..pdf
Tested on linux,ubuntu#include stdlib.h #include systypes..pdfTested on linux,ubuntu#include stdlib.h #include systypes..pdf
Tested on linux,ubuntu#include stdlib.h #include systypes..pdf
 

Recently uploaded

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
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
 
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
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
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)
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
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
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.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
 
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
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
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
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

C Program to shuffle a given Aay#include stdio.h #include .pdf

  • 1. // C Program to shuffle a given Aay #include #include #include // A utility function to print an Aay void printArray (int A[], int n) { int i; for (i = 0; i < n; i++) printf("%d ", A[i]); printf(" "); } int* shuffle(int A[], int B[]) { int n1 = 5; int n2 = 2; int i = 0, j = 0, k = 0; int *C; C = (int*)malloc(7 * sizeof(int)); // Merging starts while (i < n1 && j < n2) { if (k%2 == 0) { C[k] = A[i]; i++; k++; } else { C[k] = B[j]; k++; j++; }
  • 2. } /* elements in array 'A' are still remaining where as the array 'B' is exhausted */ while (i < n1) { C[k] = A[i]; i++; k++; } /* elements in array 'B' are still remaining where as the array 'A' is exhausted */ while (j < n2) { C[k] = B[j]; k++; j++; } return C; } int main() { int A[] = {1, 2, 3, 4, 5}; int B[] = {10, 20}; int n1 = 5; int n2 = 2; int nC = 7; int *C; C = (int*)malloc(7 * sizeof(int)); printf("Array A: "); printArray(A, n1); printf("Array B: "); printArray(B, n2);
  • 3. C = shuffle (A, B); printf(" Shuffled: "); printArray(C,nC); return 0; } /* output: Array A: 1 2 3 4 5 Array B: 10 20 Shuffled: 1 10 2 20 3 4 5 */ Solution // C Program to shuffle a given Aay #include #include #include // A utility function to print an Aay void printArray (int A[], int n) { int i; for (i = 0; i < n; i++) printf("%d ", A[i]); printf(" "); } int* shuffle(int A[], int B[]) { int n1 = 5; int n2 = 2; int i = 0, j = 0, k = 0; int *C;
  • 4. C = (int*)malloc(7 * sizeof(int)); // Merging starts while (i < n1 && j < n2) { if (k%2 == 0) { C[k] = A[i]; i++; k++; } else { C[k] = B[j]; k++; j++; } } /* elements in array 'A' are still remaining where as the array 'B' is exhausted */ while (i < n1) { C[k] = A[i]; i++; k++; } /* elements in array 'B' are still remaining where as the array 'A' is exhausted */ while (j < n2) { C[k] = B[j]; k++; j++;
  • 5. } return C; } int main() { int A[] = {1, 2, 3, 4, 5}; int B[] = {10, 20}; int n1 = 5; int n2 = 2; int nC = 7; int *C; C = (int*)malloc(7 * sizeof(int)); printf("Array A: "); printArray(A, n1); printf("Array B: "); printArray(B, n2); C = shuffle (A, B); printf(" Shuffled: "); printArray(C,nC); return 0; } /* output: Array A: 1 2 3 4 5 Array B: 10 20 Shuffled: 1 10 2 20 3 4 5 */