The source code for the above output is:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
#include<string.h> | |
int main() | |
{ | |
char name[100][100],help[20]; | |
int i,j,n; | |
printf("how many words\n"); | |
scanf("%d",&n); | |
printf("enter all the words\n"); | |
for(i=0;i<=n;i++) | |
{ | |
gets(name[i]); | |
} | |
for(i=0;i<=n;i++) | |
{ | |
for(j=i+1;j<=n;j++) | |
{ | |
if(strcmp(name[i],name[j])>0) | |
{ | |
strcpy(help,name[i]); | |
strcpy(name[i],name[j]); | |
strcpy(name[j],help); | |
} | |
} | |
} | |
printf("the words in ascending order is:"); | |
for(i=0;i<=n;i++) | |
{ | |
puts(name[i]); | |
} | |
getch(); | |
} |
0 comments :
Post a Comment