Kindly Help me with this one:Write the Code plz

QUESTION DESCRIPTION: C PROGRAM

Professor Manvi has to take attendance for her class, but the names are scattered. She has to sort the names in alphabetical order. Write a C Program to perform sorting using function and dynamic memory allocation(malloc or calloc).Condition for giving the input: Enter list of strings and type END when finished giving names.

TEST CASE 1

INPUT

suba

bala

deepa

arun

END

OUTPUT

arun

bala

deepa

suba

TEST CASE 2

INPUT

rekha

akashi

jero

liberate

parkavi

END

OUTPUT

akashi

jero

liberate

parkavi

rekha

please provide link to the question as it may be of a contest somewhere.

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

int main()
{
char **name_list, array[100];
int m, n, limit;
printf("\nEnter Total Names To Be Entered:\t");
scanf("%d", &limit);
name_list = (char **)malloc(sizeof (char *) * limit);
for(m = 0; m < limit; m++)
{
name_list[m] = (char *)malloc(sizeof (char) * 100);
}
printf("\nEnter The Names Sequentially\n");
getchar();
for(m = 0; m < limit; m++)
{
fgets(name_list[m], 100, stdin);
}
for(m = 0; m < limit - 1; m++)
{
for(n = m + 1; n < limit; n++)
{
if(strcmp(name_list[m], name_list[n]) > 0)
{
strcpy(array, name_list[m]);
strcpy(name_list[m], name_list[n]);
strcpy(name_list[n], array);
}
}
}
printf("\nAscending Order of Names:\n");
for(m = 0; m < limit; m++)
{
printf("%s", name_list[m]);
}
return 0;
}

Its my homework ,I can’t provide link sorry.Please help me

you can use linked list and then sort it.

I am new to coding and I dont understand those codinig terms ,So could u please write the code?C program

This forum is not for doing your homework . Do it yourself and ask genuine doubts . People are here to help you with your skills not your homework . Its okay if you want to learn the concept and logic .

1 Like

now atleast your task is to understand this code and write in your own way dont copy paste it and if any doubt arises feel free to ask.

this is without function now you have to do using function