FreePrograms


 

 

C language is a middle level language. It is a structured language. C language is a case sensitive language. All syntax written in c language is in lower case. C is the basis for C++.
  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions




C Program to sort the list of names of persons in alphabetical order using Bubble sort technique

#include<stdio.h>

#include<string.h>

void main(void)

{

int i,k,n;

char*name[50],*temp="";

printf("\nEnter number of persons:");

scanf("%d",&n);

for(i=0;i<n;i++) gets(name[i]);

for(k=0;k<(n-1);k++)

{

for(i=0;i<(n-k-1);i++)

{

if(strcmp(name[i],name[i+1]>0)

{

strcpy(temp,name[i]);

strcpy(name[i],name[i+1]);

strcpy(name[i+1],temp);

}

}

}

printf("\nSorted List..\n");

for(i=0;i<n;++i)

puts(name[i]);

}

 

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM