Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

C program to sort a customer list in the alphabetical list

YASH PAL, 31 July 2024

In this tutorial, we are going to write a C Program to sort a customer list in the alphabetical list in C Programming with practical program code and step-by-step full complete explanation.

C program to sort a customer list in the alphabetical list

C Program to sort a customer list in the alphabetical list.

 
#include<stdio.h>
#include<conio.h>

#define CUSTOMERS 10

void main()
{
    char first_name[20][10], second_name[20][10], surname[20][10], name[20][20], telephone[20][10], dummy[20];

    int i,j;

    printf("Input names and telephone numbers");
    printf("?");

    for(i=0;i<CUSTOMERS;i++)
    {
        scanf("%s %s %s %s", first_name[i],second_name, surname[i], telephone[i]);

        strcpy(name[i], surname[i]);
        strcat(name[i], ",");

        dummy[0]=first_name[i][0];
        dummy[1]='';

        strcat(name[i],dummy);
        stcat(name[i],".");

        dummy[0]=second_name[i][0];
        dummy[1]='';

        strcat(name[i],dummy);
    }

    for(i=1;i<=CUSTOMERS-1;i++)
    for(j=1;j<=CUSTOMERS-1;j++)
        if(strcmp(name[j-1], name[j])>0)
        {
            strcpy(dummy,name[j-1]);
            strcpy(name[j-1],name[j]);
            strcpy(name[j],dummy);
            strcpy(dummy,telephone[j-1]);
            strcpy(telephone[j-1],telephone[j]);
            strcpy(telephone[j],dummy);
        }

        printf("CUSTOMERS LIST IN ALPHABETICAL ORDER");

        for(i=0;i<CUSTOMERS;i++)
            printf("%-20st%-10s",name[i],telephone[i]);
}

Output

 
Input names and telephone numbers
? anandamurugan 9486153102
Renukadevi 9486644542

CUSTOMERS LIST IN ALPHABETICAL ORDER

anandamurugan 9486153102
Renukadevi 9486644542
c coding problems solutions

Post navigation

Previous post
Next post

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes