Write a menu-driven program to read a list of students’ surnames and perform the following: a) Print the initial list of surnames b) Sort the surnames in ascending order and print the sorted list c) Sort the surnames in descending order and print the sorted list. using c programing and write its flow chat.through user input.
#include <stdio.h>
#include <string.h>
#define MAX 50
void printList(char surname[MAX][20], int size){
int i;
printf("Surnames:\n");
for(i = 0; i < size; i++){
printf("%s\n", surname[i]);
}
}
void sortAscendingOrder(char surname[MAX][20], int size){
int i, j;
for(i = 0; i < size; i++){
for(j = 0; j < size - 1; j++){
if(strcmp(surname[j], surname[j + 1]) > 0){
char temp[20];
//Swap adjacent surnames
strcpy(temp, surname[j]);
strcpy(surname[j], surname[j + 1]);
strcpy(surname[j + 1], temp);
}
}
}
}
void sortDescendingOrder(char surname[MAX][20], int size){
int i, j;
for(i = 0; i < size; i++){
for(j = 0; j < size - 1; j++){
if(strcmp(surname[j], surname[j + 1]) < 0){
char temp[20];
//Swap adjacent surnames
strcpy(temp, surname[j]);
strcpy(surname[j], surname[j + 1]);
strcpy(surname[j + 1], temp);
}
}
}
}
int main(){
char surname[MAX][20];//Array to hold list of surnames
int size, option;
printf("How many surnames do you want to enter? ");
scanf("%d", &size);
while(size < 1 || size > MAX){
printf("Enter between 1 - %d: ", MAX);
scanf("%d", &size);
}
fflush(stdin);
int i;
for(i = 0; i < size; i++){
printf("Enter surname: ");
scanf("%s", surname[i]);
}
do{
printf("MENU\n");
printf("1. Print list\n");
printf("2. Sort list in ascending order\n");
printf("3. Sort list in descending order\n");
printf("4. Exit");
printf("Select: ");
scanf("%d", &option);
switch(option){
case 1:
{
printList(surname, size);
break;
}
case 2:
{
sortAscendingOrder(surname, size);
break;
}
case 3:
{
sortDescendingOrder(surname, size);
break;
}
case 4:
{
break;
}
default:
{
printf("Invalid option selected. Try again\n");
}
}
}while(option != 4);
return 0;
}
SAMPLE OUTPUT:

FLOWCHART:

Write a menu-driven program to read a list of students’ surnames and perform the following: a)...
Write a menu driven program to create a linked list of a class of students and perform the following operations: a. Write out the contents of the list b. Edit the details pf a specified student c. Count the number of students above 21 years and 55 kg weight
==============C++ or java================Write a modularized, menu-driven program to read a file with unknown number of records.Create a class Records to store the following data: first and last name, GPA , an Id number, and an emailInput file has unknown number of records; one record per line in the following order: first and last names, GPA , an Id number, and emailAll fields in the input file are separated by a tab (‘\t’) or a blank space (up to you)No error...
In C++
Write a menu driven C++ program to read a file containing
information for a list of Students, process the data, then present
a menu to the user, and at the end print a final report shown
below. You may(should) use the structures you developed for the
previous assignment to make it easier to complete this assignment,
but it is not required.
Required Menu Operations are:
Read Students’ data from a file to update the list (refer to
sample...
C programing Write a program to sort numbers in either descending or ascending order. The program should ask the user to enter positive integer numbers one at a time(hiting the enter key after each one) The last number entered by the user should be -1, to indicate no further numbers will be entered. Store the numbers in an array, and then ask the user how to sort the numbers (either descending or ascending). Call a function void sortnumbers ( int...
Using c++ Write a program that reads in a list of up to 25 first names from an input file nameData.txt and allows the user to display the name data, sort it in ascending or descending order, count the number of occurrences of a given name, or exit the program. The input file consists of a single names per line with each line terminated with an end of line (i.e. using Enter key to end the line). Your program should...
Write a program in C++ to read a large piece of text from the user (multiple lines) until the user inputs EOF. Assume the input only contains alphabets, numbers, commas and periods. The program should first compute the number of occurrences of each character in the input. Next, the program displays a sorted list (in descending order) of each character and the corresponding number of occurrences of that character. The sorting should be performed on the counts and not the...
Write a C++ menu driven Payroll program. Must be user friendly. Menu 1. Check data file 2. Read Data file 3. Process payroll for one employee 4. Process payroll for all employees 5. Print out to a text or an HTML file 6. Exit You must use the following Payroll classes, structures, pointers, arrays, enum, vector, recursive, advance file I/O, STL, iterators and containers. The program to process an input file below to calculate tax of 28% and output it...
Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
LANGUAGE = C i. Write a program that takes int numbers from user until user gives a sentinel value (loop terminating condition). Sort the numbers in ascending order using Insertion sort method. Sorting part should be done in different function named insertionSort(). Your code should count the number of swaps required to sort the numbers. Print the sorted list and total number of swaps that was required to sort those numbers. (4 marks) ii. In this part take another number...