Problem Requirement: A) The program must have the necessary user-defined recursi
ID: 3642142 • Letter: P
Question
Problem Requirement:A) The program must have the necessary user-defined recursive function.
B) Your program should run correctly with the same inputs and outputs as given in the sample run.
Problem Description:
Write a recursive function named two_ele_subs with one character string argument. The function will print all of the two-element subsets of a given set of letters. Write a main function with a loop to test the two_ele_subs function with different input character strings.
Hint:
void two_ele_subs( char * str )
{
Find the length of the string str
if the length is less than 2
simply return
otherwise
{
Set up a loop from the second character to the last character in str
{
Print the first character of str and the current character
}
two_ele_subs( reference to the 2nd character ); // see page 520
}
}
Explanation / Answer
main() { char *str; int ch; clrscr(); while(1) { printf(" 1.TRY 2.EXIT "); printf("Enter your choice: "); scanf("%d",&ch); if(ch==1) { printf("Enter the String: "); scanf("%s",str); two_ele_subs(str); } else exit(1); } } two_ele_subs(char *str) { int x,i; x=strlen(str); if(xRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.