How to write a C Program To Sort An Array Of Names In Alphabetical And Reverse Order in C Programming Language ?
Solution For C Program :
/*C Program To Sort An Array Of Names In Alphabetical And Reverse Order.*/
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
int i,j,k;
char name[10][10],tname[10][10],temp[10];
clrscr();
printf("How many numbers you want to store:=");
scanf("%d",&k);
printf("Enter numbers for in an array:=");
fflush(stdin);
for(i=0;i<k;i++)
{
scanf("%s",name[i]);
strcpy(tname[i],name[i]);
}
for(i=1;i<k;i++)
{
for(j=1;j<k;j++)
{
if(strcmpi(name[j],name[j-1])<0)
{
strcpy(temp,name[j-1]);
strcpy(name[j-1],name[j]);
strcpy(name[j],temp);
}
}
}
printf("The sorted names in alphabetical order [A to Z Format] are:\n");
printf("\tOldlist\t\tNew list\n\n");
for(i=0;i<k;i++)
{
printf("\t%s\t\t%s\n",tname[i],name[i]);
}
printf("\n\nThe sorted names in [Z to A Format] are:\n");
for(i=k-1;i>=0;i--)
{
printf("\t%s\n",name[i]);
}
getch();
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
Learn More :
Reverse
- C Program to Reverse a Word
- C Program Array Example: Reverse
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not
- C Program To Reverse A Number
- C Program To Reverse The String Using Pointer
- C Program To Reverse A Given Number
- C Program To Reverse A Number
- C Program to Reversing a Five Digit Integer Number
- C program to reverse an array elements using Dynamic Memory Allocation
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List
- Input Number and Print it's Reverse C Program
Array
- How to pass one dimensional array to function in c.
- Write a c program which passes two dimension array to function.
- C Program Array Index Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program Array Example
- C Program to Array
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Find The Maximum And Minimum Value In An Array
- C Program To Find Union & Intersection Of Two Array
- C Program To Search A Number Inside The Array
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Copy One Character Array Into Another
- Returns: array of decoded values. [0] - count of values
- C Program to Check if a number is in an array[1000]
- C Program to Find max and min in array using pointer concept
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to find smallest in an array using pointer
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- C Program to Array Deserialization
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- Input reads in the array positions and range for random generation.
Alphabet
Sort
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program Sort Example
- C Program Shell Sort Using C Programming Language
- C Program Selection Sort Using C Programming Language
- C Program to Bubble Sort Using C Programming Language
- C Program Insertion Sort Using C Programming Language
- Heap Sort Using C Programming Language
- C Program To Sort An Array In Ascending And Descending Order
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- matrix sort in C Program
- C program that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user,store these numbers into an array & sort the number of an array
- C Program to Implement Quick Sort
- QuickVSInsertion Sorting C Program