C design for Sorting N strings in Alphabetical Order # accommodate <stdio.h> #include <conio.h> #include <string.h>  void main() { coal name[10][8], Tname[10][8], temp[8]; int i, j, N;  clrscr();  printf(Enter the value of N\n); scanf(%d, &N);  printf(Enter %d name calling\n, N); for(i=0; i< N ; i++) { scanf(%s,name[i]); strcpy (Tname[i], name[i]); }  for(i=0; i < N-1 ; i++) { for(j=i+1; j< N; j++) { if(strcmpi(name[i],name[j]) > 0) { strcpy(temp,name[i]); strcpy(name[i],name[j]); strcpy(name[j],temp); } } }  printf(\n----------------------------------------\n); printf(Input Names\tSorted names\n); printf(------------------------------------------\n); for(i=0; i< N ; i++) { printf(%s\t\t%s\n,Tname[i], name[i]); } printf(------------------------------------------\n);  } c program to sort names [strings] in ascending dress. #include<stdio.h> #include<string.h> //#include<conio.
h> void main() {   int num,i,j,result,index;   char name[25][25];       //declaring array of strings   char temp[25];            //clrscr();   printf(\nNumber of names to be sorted in ascending order\n);   scanf(%d,&num);   printf(Enter %d names to be sorted\n,num);   for(i=0;i<num;i++)     scanf(%s,name[i]);       //input the names   for(i=0;i<num;i++)   {     index=i;              for(j=i+1;j<num;j++)     {    result=strcmp(name[index],name[j]);        //logical system for sorting    if(result>0)                    index=j;     }     strcpy(temp,name[index]);     strcpy(name[index],name[i]);          //Logic to Swap strings using string functions.     strcpy(name[i],temp);   }   printf(\nNames Sorted in Ascending Order\n);   for(i=0;i<num;i++)   {    printf(\t%s,name[i]);   }   //getch(); } c program to... If you want to get a full essay, order it on our website: Ordercustompaper.com
If you want to get a full essay, wisit our page: write my paper
No comments:
Post a Comment