Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lisp Scheme Write a procedure called charflip that takes a string as a parameter

ID: 3672913 • Letter: L

Question

Lisp Scheme
Write a procedure called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..)
I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions:
• char-upper-case? • char-downcase • char-upcase • list->string • string->list
Here’s this function in action.
scheme@(guile-user)> (charflip "hatburg") $16 = "hAtBuRg" Lisp Scheme
Write a procedure called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..)
I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions:
• char-upper-case? • char-downcase • char-upcase • list->string • string->list
Here’s this function in action.
scheme@(guile-user)> (charflip "hatburg") $16 = "hAtBuRg" Lisp Scheme
Write a procedure called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..)
I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions:
• char-upper-case? • char-downcase • char-upcase • list->string • string->list
Here’s this function in action.
scheme@(guile-user)> (charflip "hatburg") $16 = "hAtBuRg"

Explanation / Answer

#include <stdio.h>
#include <string.h>
int main() {
char string[100], even[100], odd[100], i, j, k;
i = j = k = 0;
/* get the input string from the user */
printf("Enter your input string:");
fgets(string, 100, stdin);
string[strlen(string) - 1] = '';
/* printing the input string */
printf("Given Input string:%s ", string);
/*
* print the characters at odd position in odd array.
* Similarly, print the characters at even position in
* even array.
*/
while (string[i] != '') {
if (i % 2 == 0) {
odd[j++] = string[i];
} else {
even[k++] = string[i];
}
i++;
}
/* terminating even and odd string with NULL */
odd[j] = even[k] = '';
/* print the charactersa at odd position and even positions */
printf("Characters at odd position: %s ", odd);
printf("Characters at even position: %s ", even);
return 0;
}

Output:

Enter your input string:HelloWorld

Given Input string:HelloWorld
Characters at odd position: Hlool
Characters at even position: elWrd

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote