Posts

Showing posts with the label veer dhakad

short the string in alphabatical order

#include<stdio.h> #include<string.h> void main() {   int n,i,k=0,j;   char temp[20];   printf("how many cities you want to insert in ");   scanf("%d",&n);   char city[n][20];   char cty[n][20];   printf("enter the name of cities\n");   for(i=0;i<n;i++)   {    scanf("\n%s",city[i]);   }   for(i=0;i<n;i++)   {    printf("\n%s",city[i]);   }   for(i=65;i<=122;i++)   {       for(j=0;j<n;j++)       {           if(city[j][0]==i)           {             strcpy(cty[k],city[j]);             k++;           }       }   }   printf("after shorting\n");   for(i=0;i<n;i++)   {    printf("\n%s",cty[i]);   } }