SHARE
TWEET

Untitled

a guest Apr 24th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. int main(void) {
  7.  
  8.     //declaration
  9.     int i, j, count;
  10.     char str[25][25], temp[25];
  11.  
  12.     //Questions
  13.     puts("How many strings u are going to enter?: ");
  14.     scanf_s("%d", &count);
  15.  
  16.     puts("Enter Strings one by one: ");
  17.     for (i = 0;i <= count;i++) {
  18.         gets(str[i]);
  19.     }
  20.  
  21.     //Sorting strings
  22.     for (i = 0;i <= count;i++)
  23.         for (j = i + 1;j <= count;j++) {
  24.             if (strcmp(str[i], str[j])>0) {
  25.                 strcpy(temp, str[i]);
  26.                 strcpy(str[i], str[j]);
  27.                 strcpy(str[j], temp);
  28.             }
  29.         }
  30.  
  31.     //Printing
  32.     printf("Order of Sorted Strings:");
  33.     for (i = 0;i <= count;i++) {
  34.         puts(str[i]);
  35.     }
  36.  
  37.     system("pause");
  38.  
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top