Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

Sort a string array in ascending order

Code: 
//Write a C program to sort a string array in ascending order.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
  char st[20],ch;
  int i,j,l;
  clrscr();
  printf("enter any string:");
  gets(st);
  l=strlen(st);
  /* sorting process */
  for(i=1;i<l;i++)
    for(j=0;j<l-i;j++)
if(st[j]>st[j+1])
{
 ch=st[j];
 st[j] = st[j+1];
 st[j+1]=ch;
}
   printf("Sorted string is \n");
   printf("%s\n",st);
  getch();
  }

 

APPLICATIONS & TECHNOLOGIES

Learn about the latest applications and industry trends with tutorials and white paper design resources on vertical markets.

Automotive
Energy Harvesting
MEMS Technology
OpenSource Hardware
RFID & NFC
RF Wireless
Sensor
Solar
Touch
Wireless Charging

 

You are here