Computer Programming C Laboratory: Arrays C Programs

C Program to sort the given strings alphabetically (Array)

Arrays C Programs

C Program to sort the given strings alphabetically.

/* Program to sort the given strings alphabetically */

#include <stdio.h>

#include <conio.h>

#include <ctype.h>

void main()

{

        int i,j;

        char b[20];

        printf("Enter the text to sort : ");

        gets (b);

        printf("Sorted Text are: ");

        for(i=65;i<=90;i++)

        {

                for(j=0;j<30;j++)

                {

                        if(b[j]==toupper(i) || b[j]==tolower(i))

                        printf("%c", b[j]);

                } /* for */

        } /* for */

        getch();

} /* main */

OUTPUT:

Enter the text to sort: VRBPublishers

Sorted Text are : BbehilPRrssuV


EXPLANATION: The above program gets the string characters from the keyboard. ASCII equivalents of alphabets are used to sort out the given string. The toupper() and tolower() string functions in if statement used to ignore the priority of characters i.e., capital or small letters are treated the same. If the character value given by for loop i and string b[] value denoted by for loop j are same that value gets printed. Because the value of a character supplied by the outer for loop are taken alphabetically.



Computer Programming C Laboratory: Arrays C Programs : Tag: C Programming : - C Program to sort the given strings alphabetically (Array)


Computer Programming C Laboratory: Arrays C Programs



Under Subject


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation



Related Subjects


English Essentials I

EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


தமிழர் மரபு - Heritage of Tamils

UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Calculus

MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I

PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Chemistry I

CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Makerspace

ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming Python

CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Fundamentals of Electrical and Electronics Engineering

EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Mechanical Engineering

ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Civil Engineering

CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing

CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I Laboratory

PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Applied Chemistry I Laboratory

CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming Python Laboratory

CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electronics and Electrical Engineering

EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing - Laboratory

CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation