i can't pin-point where i'm really going wrong but i would like to design aprogramme that takes 5 names as inputs from keyboard ,arranges the names in alphabetical order.my programme goes like below:
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j;
char temp[20];
char names[5][20];
clrscr();
printf("Enter names:\n");
for(i=0;i<5;i++)
scanf("%s",names);
for(i=0;i<4;i++)
for(j=i+1;j<5;j++)
if(strcmp(names[i],names[j])>0)
{
strcpy(temp,names[i]);
strcpy(names[i],names[j]);
strcpy(names[i],temp);
}
getchar();
return;
}
Please Help!
The programme is just outputting the names as they were just entered.
[code][/code]tagged by Salem