0% found this document useful (0 votes)
74 views

Search On Codescracker Search: F T G L y

Uploaded by

Sreejith PB
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Search On Codescracker Search: F T G L y

Uploaded by

Sreejith PB
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

C Program to Sort Strings in Alphabetical Order Page 1 of 6

f t g l y

search on codescracker Search

Home
Java
C
C++
HTML
CSS
JavaScript
SQL
PHP
Perl
Python
C#
Objective-C
Tips

C Programming Examples
C Programming Examples
Print Hello World
Take Input from User
Print Integer
Add two Numbers
Check Even or Odd
Check Prime or Not
Check Alphabet or Not
Check Vowel or Not
Check Leap Year or Not
Check Reverse equal Original
Add Subtract Multiply Divide
Make Calculator
Add Digits of Number
Calculate Average Percentage Marks
Calculate Arithmetic Mean
Calculate Student Grade
Print Table of Number
Print Prime Numbers
Add n Numbers
Interchange Numbers
Reverse Numbers
Swap two Numbers
Count Positive Negative Zero
Find Largest of two Numbers
Find Largest of three Numbers
Find Factorial of Number
Find HCF LCM
Calculate Area Perimeter
Calculate Area Circumference
Fahrenheit to Centigrade Conversion
Centigrade to Fahrenheit Conversion
Print ASCII Values
Print Fibonacci Series
Check Palindrome or Not
Check Armstrong or Not
Generate Armstrong Numbers

https://codescracker.com/c/program/c-program-sort-string.htm 02-05-17
C Program to Sort Strings in Alphabetical Order Page 2 of 6

Find ncR nPr


Decimal to Binary Conversion
Decimal to Octal Conversion
Decimal to Hexadecimal Conversion
Binary to Decimal Conversion
Binary to Octal Conversion
Binary to Hexadecimal Conversion
Octal to Decimal Conversion
Octal to Binary Conversion
Octal to Hexadecimal Conversion
Hexadecimal to Decimal Conversion
Hexadecimal to Binary Conversion
Hexadecimal to Octal Conversion
Pattern Printing Programs
Print Diamond Pattern
Print Floyd Triangle
Print Pascal Triangle
Print smiling face
One Dimensional Array Program
Linear Search
Binary Search
Add Two Numbers using Pointer
Find Largest Element in Array
Find Smallest Element in Array
Reverse Array
Insert Element in Array
Delete Element from Array
Merge two Array
Bubble Sort
Selection Sort
Insertion Sort
Two Dimensional Array Program
Add two Matrices
Subtract Matrices
Transpose Matrix
Multiply Matrices
Three Dimensional Array Program
Print String
Find Length of String
Compare two String
Copy String
Concatenate String
Reverse String
Delete Vowels from String
Delete Words from Sentence
Find Frequency of Character
Count Word in Sentence
Remove Spaces from String
Sort a String
Convert Uppercase to Lowercase
Convert Lowercase to Uppercase
Swap two Strings
Check Anagram or Not
Generate Random Numbers
Read File
Write to File
Read & Display File
Copy File
Merge two File
List Files in Directory
Delete File
Encrypt and Decrypt Files
Print Date
Get IP Address
Shutdown Computer
C Programming Tutorial
C Tutorial
C Programming Functions
C Functions
C Programming Test
C Online Test
Give Online Test
Register Now
Login Page

https://codescracker.com/c/program/c-program-sort-string.htm 02-05-17
C Program to Sort Strings in Alphabetical Order Page 3 of 6

All Test List

C Program to Sort Strings in Alphabetical Order

Start your first VM for free


Google Cloud Platform. with Google Compute
Engine.

« Previous Program Next Program »

Sort Strings in C

To sort strings in alphabetical order in C programming, you have to ask to the user to enter some set of strings (5
strings here). Now start comparing one strings with other and sort all the strings in alphabetical order then display
all the strings in alphabetical order as shown here in the following program.

C Programming Code to Sort Strings in Alphabetical Order

Following C program ask to the user to enter five strings like names to sort them in alphabetical order then display
the sorted strings in alphabetical order on the screen:

/* C Program - Sort Strings */

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[5][20], t[20];
int i, j;
printf("Enter any five string (name) : ");
for(i=0; i<5; i++)
{
scanf("%s",str[i]);
}
for(i=1; i<5; i++)
{
for(j=1; j<5; j++)
{
if(strcmp(str[j-1], str[j])>0)
{
strcpy(t, str[j-1]);
strcpy(str[j-1], str[j]);
strcpy(str[j], t);
}
}
}
printf("Strings (Names) in alphabetical order : \n");
for(i=0; i<5; i++)
{
printf("%s\n",str[i]);
}
getch();
}

When the above c program is compile and executed, it will produce the following result:

https://codescracker.com/c/program/c-program-sort-string.htm 02-05-17
C Program to Sort Strings in Alphabetical Order Page 4 of 6

Same Program in Other Programming Language

You may also like same program in other programming languages:

C++ Sort Strings in Alphabetical Order


Java Sort Strings in Alphabetical Order
Python Sort Strings in Alphabetical Order

C Online Test

« Previous Program Next Program »

https://codescracker.com/c/program/c-program-sort-string.htm 02-05-17
C Program to Sort Strings in Alphabetical Order Page 5 of 6

Tools
Calculator

Quick Links
Signup - Login - Give Online Test

C++ Program
to Sort...

C++ Program
to Print...

C Program to
Print...

C Program to
Check...

C Program to
Check...

C Program to
Convert...

Python
Program to...

C Program to
Print Date

C Program
Linear Search

C Program to
Insert...

C++ File
Handling

C++ Program
Selection Sort

C++
Functions

https://codescracker.com/c/program/c-program-sort-string.htm 02-05-17
C Program to Sort Strings in Alphabetical Order Page 6 of 6

Tutorials Online Tests Online Tests Examples


Java Tutorial All Test Objective-C Test Java Examples
C Tutorial Java Test Data Structure Test C Examples
C++ Tutorial C Test Computer Fundamental Test C++ Examples
HTML Tutorial C++ Test Operating System Test Python Examples
JavaScript Tutorial HTML Test Networking Test Interview Questions
PHP Tutorial CSS Test Microsoft Word Test Java Interview Questions
CSS Tutorial JavaScript Test Microsoft Excel Test References
SQL Tutorial SQL Test Microsoft PowerPoint Test C Functions
Python Tutorial PHP Test Computer Hardware Test HTML Character Entities
C# Tutorial Perl Test Linux Test HTML Color Codes
Perl Tutorial Python Test Unix Test Computer Tips & Tricks
Objective-C Tutorial C# Test MySQL Test Computer Networking

© Copyright 2017 CodesCracker.com. All Rights Reserved.

codescracker.com

https://codescracker.com/c/program/c-program-sort-string.htm 02-05-17

You might also like