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

Create a program to do the following: 1) Read in names to sort until the user ty

ID: 3811549 • Letter: C

Question

Create a program to do the following:

1) Read in names to sort until the user types the “enter” key as the first character of a “C-type” string (the maximum number of names is 20, there is not a maximum length to a name), using a two dimensional array of characters.

2) After sorting and displaying the array of “C-type” strings, ask the user for a “C-type” string to search for (again, no maximum length).

3) Do a binary search to find if the “C-type” string is in the array

4) If the “C-type” string is in the array, tell the user the index of the “C-type” string.

5) If the “C-type” string is not in the array, tell the user that it is missing.

6) Repeat items 3 thru 5 until the user enters the “enter” key as the first character of the “C-type” string, at which time the program will complete.

BONUS: A bonus of 20 points if you create the program in such a way that there is no limit on the number of names to be handled.

P.S : If possible use the Bubblesort on the first part.

Explanation / Answer

/*This solution takes input of twenty strings any string does'nt have bounds. Then it prints the Strings in the array*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
   char character;
   struct Node *next;
};


int main(void) {
    int i=0,j,n,flag;
    struct Node *str[20],*temp,*temp1;
  
    temp=(struct Node *)malloc(sizeof(struct Node));
    scanf("%c",&temp->character);
    //printf("%c",temp->character);
    while((temp->character != ' ') && i<20){
        //str[i]=temp;
        flag=0;
        while(temp->character != ' '){
            if(flag == 0){
                str[i]=temp;
                temp1=temp;
                flag=1;
            }
            else{
                temp1->next=temp;
                temp1=temp;
            }
            temp=(struct Node *)malloc(sizeof(struct Node));
            scanf("%c",&temp->character);
        }
        temp=(struct Node *)malloc(sizeof(struct Node));
        temp->character='';
        temp1->next=temp;
        i++;
        temp=(struct Node *)malloc(sizeof(struct Node));
        scanf("%c",&temp->character);
    }
    temp1->next = temp;
  
    i=0;
    temp1=str[0];
    while((temp1->character != ' ') && i<20){
        temp1=str[i];
        while(temp1->character != ''){
            printf("%c",temp->character);
            temp1=temp1->next;
        }
        printf("%c",' ');
        i++;
    }
   return 0;
}

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