SlideShare a Scribd company logo
1 of 2
Write functions odd and even, which takes a list of symbols L, and produces a sublist of L
containing symbols located at odd and even positions repectively. E.g., (odd '(a b c d)) = (a c)
(even '(a b c d)) = (b d) (odd '(a)) = (a) (even '(a)) = ()
Solution
//just assumed that the size of array is 10 you can chnage it accordingly
void oddAndEven(char arr[10])
{
char sublistodd[5],sublisteven[5];
int j,k;
for(int i=0; i <10 ; i++)
{
if(i/2 == 0 && i<=4)
{
sublisteven[i] = arr[i];
j = i;
j=j+1;
}
else if(i/2 != 0 && i<=4)
{
sublistodd[i] = arr[i];
k = i;
k++;
}
else if(i/2 == 0 && i>4 && j<5)
{
sublisteven[j] = arr[i];
j++;
}
else if(i/2 !=0 && i>4 && k<5)
{
sublistodd[k] = arr[i];
k++;
}
}
}

More Related Content

More from karlynwih

Write an SML function groupdupes that takes a list of integers as its.docx
Write an SML function groupdupes that takes a list of integers as its.docxWrite an SML function groupdupes that takes a list of integers as its.docx
Write an SML function groupdupes that takes a list of integers as its.docxkarlynwih
 
You and another tech are discussing the relative merits of SCSI interf.docx
You and another tech are discussing the relative merits of SCSI interf.docxYou and another tech are discussing the relative merits of SCSI interf.docx
You and another tech are discussing the relative merits of SCSI interf.docxkarlynwih
 
Write an application class (ArrayListApplication) that contains a main.docx
Write an application class (ArrayListApplication) that contains a main.docxWrite an application class (ArrayListApplication) that contains a main.docx
Write an application class (ArrayListApplication) that contains a main.docxkarlynwih
 
Write an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxWrite an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxkarlynwih
 
write a topic about RFID in SCM and what you have learned about adopti.docx
write a topic about RFID in SCM and what you have learned about adopti.docxwrite a topic about RFID in SCM and what you have learned about adopti.docx
write a topic about RFID in SCM and what you have learned about adopti.docxkarlynwih
 
Write up a simple c-program to find the median of any array-Solution#i.docx
Write up a simple c-program to find the median of any array-Solution#i.docxWrite up a simple c-program to find the median of any array-Solution#i.docx
Write up a simple c-program to find the median of any array-Solution#i.docxkarlynwih
 
Write an assembly language program in the Pep-8 simulator that corresp.docx
Write an assembly language program in the Pep-8 simulator that corresp.docxWrite an assembly language program in the Pep-8 simulator that corresp.docx
Write an assembly language program in the Pep-8 simulator that corresp.docxkarlynwih
 
Write the for structure in JAVA coding to read and display all element.docx
Write the for structure in JAVA coding to read and display all element.docxWrite the for structure in JAVA coding to read and display all element.docx
Write the for structure in JAVA coding to read and display all element.docxkarlynwih
 
Write the formal description of the following state machine (M) What.docx
Write the formal description of the following state machine (M)  What.docxWrite the formal description of the following state machine (M)  What.docx
Write the formal description of the following state machine (M) What.docxkarlynwih
 
Write the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docxWrite the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docxkarlynwih
 
Write the balanced reaction where thiosulfate and protons are the only.docx
Write the balanced reaction where thiosulfate and protons are the only.docxWrite the balanced reaction where thiosulfate and protons are the only.docx
Write the balanced reaction where thiosulfate and protons are the only.docxkarlynwih
 
Write about the two sources of energy Write about the two sources of.docx
Write about the two sources of energy   Write about the two sources of.docxWrite about the two sources of energy   Write about the two sources of.docx
Write about the two sources of energy Write about the two sources of.docxkarlynwih
 

More from karlynwih (12)

Write an SML function groupdupes that takes a list of integers as its.docx
Write an SML function groupdupes that takes a list of integers as its.docxWrite an SML function groupdupes that takes a list of integers as its.docx
Write an SML function groupdupes that takes a list of integers as its.docx
 
You and another tech are discussing the relative merits of SCSI interf.docx
You and another tech are discussing the relative merits of SCSI interf.docxYou and another tech are discussing the relative merits of SCSI interf.docx
You and another tech are discussing the relative merits of SCSI interf.docx
 
Write an application class (ArrayListApplication) that contains a main.docx
Write an application class (ArrayListApplication) that contains a main.docxWrite an application class (ArrayListApplication) that contains a main.docx
Write an application class (ArrayListApplication) that contains a main.docx
 
Write an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxWrite an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docx
 
write a topic about RFID in SCM and what you have learned about adopti.docx
write a topic about RFID in SCM and what you have learned about adopti.docxwrite a topic about RFID in SCM and what you have learned about adopti.docx
write a topic about RFID in SCM and what you have learned about adopti.docx
 
Write up a simple c-program to find the median of any array-Solution#i.docx
Write up a simple c-program to find the median of any array-Solution#i.docxWrite up a simple c-program to find the median of any array-Solution#i.docx
Write up a simple c-program to find the median of any array-Solution#i.docx
 
Write an assembly language program in the Pep-8 simulator that corresp.docx
Write an assembly language program in the Pep-8 simulator that corresp.docxWrite an assembly language program in the Pep-8 simulator that corresp.docx
Write an assembly language program in the Pep-8 simulator that corresp.docx
 
Write the for structure in JAVA coding to read and display all element.docx
Write the for structure in JAVA coding to read and display all element.docxWrite the for structure in JAVA coding to read and display all element.docx
Write the for structure in JAVA coding to read and display all element.docx
 
Write the formal description of the following state machine (M) What.docx
Write the formal description of the following state machine (M)  What.docxWrite the formal description of the following state machine (M)  What.docx
Write the formal description of the following state machine (M) What.docx
 
Write the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docxWrite the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docx
 
Write the balanced reaction where thiosulfate and protons are the only.docx
Write the balanced reaction where thiosulfate and protons are the only.docxWrite the balanced reaction where thiosulfate and protons are the only.docx
Write the balanced reaction where thiosulfate and protons are the only.docx
 
Write about the two sources of energy Write about the two sources of.docx
Write about the two sources of energy   Write about the two sources of.docxWrite about the two sources of energy   Write about the two sources of.docx
Write about the two sources of energy Write about the two sources of.docx
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 

Write functions odd and even- which takes a list of symbols L- and pro.docx

  • 1. Write functions odd and even, which takes a list of symbols L, and produces a sublist of L containing symbols located at odd and even positions repectively. E.g., (odd '(a b c d)) = (a c) (even '(a b c d)) = (b d) (odd '(a)) = (a) (even '(a)) = () Solution //just assumed that the size of array is 10 you can chnage it accordingly void oddAndEven(char arr[10]) { char sublistodd[5],sublisteven[5]; int j,k; for(int i=0; i <10 ; i++) { if(i/2 == 0 && i<=4) { sublisteven[i] = arr[i]; j = i; j=j+1; } else if(i/2 != 0 && i<=4) { sublistodd[i] = arr[i]; k = i; k++; } else if(i/2 == 0 && i>4 && j<5) { sublisteven[j] = arr[i]; j++; } else if(i/2 !=0 && i>4 && k<5) { sublistodd[k] = arr[i]; k++;