Question: #include #include #include #include #define MAX _ ENTRIES 1 0 #define WORD _ LENGTH 2 0 struct DictEnglishTurkishEntry { char english [ WORD _ LENGTH

#include
#include
#include
#include
#define MAX_ENTRIES 10
#define WORD_LENGTH 20
struct DictEnglishTurkishEntry {
char english[WORD_LENGTH];
char turkish[WORD_LENGTH];
};
struct DictEnglishTurkishEntry dictionary[MAX_ENTRIES];
int nextElement[MAX_ENTRIES]; // Array to store the index of the next element
int entryCount =0;
int startIndex =-1; // Start index of the dictionary
// Function to convert a word to lowercase
void capitalizationControl(char word[]){
int i =0;
while (word[i]!='\0'){// Loop until the end of the string
word[i]= tolower(word[i]); // Convert each character to lowercase
i++;
}
}
// Function to find the position to insert a new word to keep the dictionary sorted
int findInsertPosition(char englishWord[]){
int i = startIndex;
int prev =-1;
while (i !=-1 && strcmp(dictionary[i].english, englishWord)<0){
prev = i;
i = nextElement[i];
}
return prev;
}
void addEntry(){
if (entryCount >= MAX_ENTRIES){
printf("Dictionary is full. No addition can be made.
");
return;
}
char englishWord[WORD_LENGTH];
char turkishWord[WORD_LENGTH];
printf("Enter English word: ");
scanf("%s", englishWord);
capitalizationControl(englishWord);
printf("Enter Turkish meaning: ");
scanf("%s", turkishWord);
capitalizationControl(turkishWord); // Apply capitalization control to Turkish word as well
// Insert the word at the end of the dictionary
strcpy(dictionary[entryCount].english, englishWord);
strcpy(dictionary[entryCount].turkish, turkishWord);
// Find the correct position to insert this entry in the sorted list
int prevIndex = findInsertPosition(englishWord);
if (prevIndex ==-1){// Insert at the beginning
nextElement[entryCount]= startIndex;
startIndex = entryCount;
} else {// Insert in the middle or at the end
nextElement[entryCount]= nextElement[prevIndex];
nextElement[prevIndex]= entryCount;
}
entryCount++;
printf("Entry added successfully.
");
}
void deleteEntry(){
if (entryCount ==0){
printf("Dictionary is empty. No deletion can be made.
");
return;
}
char englishWord[WORD_LENGTH];
printf("Enter English word to delete: ");
scanf("%s", englishWord);
capitalizationControl(englishWord);
int i = startIndex;
int prev =-1;
int found =0;
int lastIndex = entryCount -1;
while (i !=-1){
if (strcmp(dictionary[i].english, englishWord)==0){
found =1;
if (prev ==-1){
startIndex = nextElement[i];
} else {
nextElement[prev]= nextElement[i];
}
if (i != lastIndex){
// Move the last entry to the position of the deleted entry
strcpy(dictionary[i].english, dictionary[lastIndex].english);
strcpy(dictionary[i].turkish, dictionary[lastIndex].turkish);
nextElement[i]= nextElement[lastIndex];
}
nextElement[lastIndex]=-1; // Mark the last entry as unused
entryCount--;
printf("Entry deleted successfully.
");
break;
}
prev = i;
i = nextElement[i];
}
if (!found){
printf("Word not found in the dictionary.
");
}
}
void printEntries(){
if (entryCount ==0){
printf("Dictionary is empty.
");
return;
}
printf("English\t\tTurkish
");
int i = startIndex;
while (i !=-1){
printf("%s\t\t%s
", dictionary[i].english, dictionary[i].turkish);
i = nextElement[i];
}
}
int main(){
int choice;
do {
printf("
Dictionary Menu:
");
printf("1) Add an entry
");
printf("2) Delete an entry
");
printf("3) Print the entries in order
");
printf("4) Quit
");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice){
case 1:
addEntry();
break;
case 2:
deleteEntry();
break;
case 3:
printEntries();
break;
case 4:
printf("Exiting...
");
break;
default:
printf("Invalid choice. Please try again.
");
}
} while (choice !=4);
return 0;
} could you please draw in paper (flowchart ) for this code .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!