Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to sort a list in alphabatic order using pointers

Posted By: Reginald Fischer     Category: C Programming     Views: 15011

Write a program to sort a list in alphabatic order using pointers.

Code for Program to sort a list in alphabatic order using pointers in C Programming

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <alloc.h>
void main()
{

char *a[10],dum[10],s;
int i,k,j,n;
clrscr();
printf("enter the no of std....");
scanf("%d",&n);
printf("enter the name of students ");
for(k=0;k<n;k++)
scanf("%s",a[k]);
for(i=1;i<n;i++)
{
for(j=1;j<n-i;j++)
{if(strcmp(a[j-1],a[j])>0)
  {strcpy(*dum,*a[j-1]);
   strcpy(*a[j-1],*a[j]);
   strcpy(*a[j],*dum);
 }
 }  }
 for(i=0;i<n;i++)
 printf("%s",a[i]);
 getch();
 }
  
Share: 


Didn't find what you were looking for? Find more on Program to sort a list in alphabatic order using pointers Or get search suggestion and latest updates.

Reginald Fischer
Reginald Fischer author of Program to sort a list in alphabatic order using pointers is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!