SlideShare a Scribd company logo
#include <stdio.h>
#include <string.h>
int main()
{
char name[20][10], tname[20][10], temp[10];
int i, j, n;
printf("Enter the number of Names you want to do input:n"); //how many names input
scanf("%d", &n);
printf("Enter names: n");
for (i = 0; i < n; i++)
{
scanf("%s", name[i]);
strcpy(tname[i], name[i]);
} //input names
for (i = 0; i < n - 1 ; i++)
{
for (j = i + 1; j < n; j++)
{
if (strcmp(name[i], name[j]) > 0)
{ strcpy(temp, name[i]);
strcpy(name[i], name[j]);
strcpy(name[j], temp);
}
}
} //for alphabetically sorting
printf("n----------------------------------------n");
printf(" Input || NamestSorted namesn");
printf("------------------------------------------n");
for (i = 0; i < n; i++)
{
printf("%st || t%sn", tname[i], name[i]); //printf storted names
}
printf("------------------------------------------n");
}
By Samsil Arefin
Samsilarefin017@gmail.com

More Related Content

PDF
Insertion sort
DOCX
Document
PDF
Dfs implementation in c
PDF
Bcsl 033 data and file structures lab s2-3
PDF
Bcsl 033 data and file structures lab s2-2
TXT
Dvst
PDF
Linked list searching deleting inserting
Insertion sort
Document
Dfs implementation in c
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-2
Dvst
Linked list searching deleting inserting

What's hot (20)

DOC
Data structure
PDF
Linked list int_data_fdata
DOCX
Circular queue
PDF
Bcsl 033 data and file structures lab s2-1
PDF
DOCX
basic programs in C++
PPTX
Elf文件解析
PDF
Bcsl 033 data and file structures lab s1-3
TXT
Fred
DOCX
Stack array
PPTX
Lecture 1 string functions
PDF
Bcsl 033 data and file structures lab s3-3
DOCX
Artificial intelligence
DOCX
SaraPIC
DOCX
Ejercicios de programacion
PDF
Grestest2
DOCX
New microsoft word document
Data structure
Linked list int_data_fdata
Circular queue
Bcsl 033 data and file structures lab s2-1
basic programs in C++
Elf文件解析
Bcsl 033 data and file structures lab s1-3
Fred
Stack array
Lecture 1 string functions
Bcsl 033 data and file structures lab s3-3
Artificial intelligence
SaraPIC
Ejercicios de programacion
Grestest2
New microsoft word document
Ad

Viewers also liked (12)

PPTX
examen bimestral
PDF
מבוא לתכנות מדעי פייתון הרצאה 3 חלק 2 Python
PPTX
Practica pp
PDF
Linked list Output tracing
PDF
J0017870
PDF
Hidden beansppt
DOCX
свято миколая 2015документ microsoft word
PDF
Laura frade-competencias
PDF
3 Steps To Take After an Interview
PDF
투비즈(TOOBEEZ) 팜플렛
PPTX
Como Pronunciar O Alfabeto Em Inglês
PPTX
Kurento v6 Development Guide
examen bimestral
מבוא לתכנות מדעי פייתון הרצאה 3 חלק 2 Python
Practica pp
Linked list Output tracing
J0017870
Hidden beansppt
свято миколая 2015документ microsoft word
Laura frade-competencias
3 Steps To Take After an Interview
투비즈(TOOBEEZ) 팜플렛
Como Pronunciar O Alfabeto Em Inglês
Kurento v6 Development Guide
Ad

Similar to Program to sort the n names in an alphabetical order (20)

DOCX
C lab manaual
PDF
C programms
DOCX
ADA FILE
DOCX
DAA Lab File C Programs
PPTX
4. chapter iii
PPTX
Structure
PPTX
Structure
PDF
String
PPTX
PDF
Basic C Programming Lab Practice
PDF
Cpd lecture im 207
PDF
VTU Data Structures Lab Manual
PDF
Data Structure using C
PDF
C Language Lecture 13
PPTX
LAB PROGRAMS SARASWATHI RAMALINGAM
PDF
COgdfgdffgdgfgdasdasdaffadadsdsd5ANS.pdf
PDF
codes.txt.pdf code presentation engineering
PDF
Data Structure in C Programming Language
C lab manaual
C programms
ADA FILE
DAA Lab File C Programs
4. chapter iii
Structure
Structure
String
Basic C Programming Lab Practice
Cpd lecture im 207
VTU Data Structures Lab Manual
Data Structure using C
C Language Lecture 13
LAB PROGRAMS SARASWATHI RAMALINGAM
COgdfgdffgdgfgdasdasdaffadadsdsd5ANS.pdf
codes.txt.pdf code presentation engineering
Data Structure in C Programming Language

More from Samsil Arefin (20)

PPTX
Transmission Control Protocol and User Datagram protocol
PDF
Evolution Phylogenetic
PPTX
Evolution Phylogenetic
PDF
Ego net facebook data analysis
PPTX
Augmented Reality (AR)
PPTX
Client server chat application
PPTX
Strings in programming tutorial.
PPTX
Number theory
PDF
PPT
Sorting
PPTX
Fundamentals of-electric-circuit
PPTX
Cyber security
PDF
C programming
PPTX
Data structure lecture 1
PPT
Structure and union
PPT
Structure in programming in c or c++ or c# or java
PPTX
PPTX
String in programming language in c or c++
PPTX
Game Development
PPTX
File in C programming
Transmission Control Protocol and User Datagram protocol
Evolution Phylogenetic
Evolution Phylogenetic
Ego net facebook data analysis
Augmented Reality (AR)
Client server chat application
Strings in programming tutorial.
Number theory
Sorting
Fundamentals of-electric-circuit
Cyber security
C programming
Data structure lecture 1
Structure and union
Structure in programming in c or c++ or c# or java
String in programming language in c or c++
Game Development
File in C programming

Recently uploaded (20)

PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPTX
Geodesy 1.pptx...............................................
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT 4 Total Quality Management .pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
PPT on Performance Review to get promotions
PPTX
Artificial Intelligence
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
additive manufacturing of ss316l using mig welding
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Geodesy 1.pptx...............................................
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Fundamentals of safety and accident prevention -final (1).pptx
Internet of Things (IOT) - A guide to understanding
Mechanical Engineering MATERIALS Selection
UNIT 4 Total Quality Management .pptx
III.4.1.2_The_Space_Environment.p pdffdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Model Code of Practice - Construction Work - 21102022 .pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPT on Performance Review to get promotions
Artificial Intelligence
CH1 Production IntroductoryConcepts.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
additive manufacturing of ss316l using mig welding
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks

Program to sort the n names in an alphabetical order

  • 1. #include <stdio.h> #include <string.h> int main() { char name[20][10], tname[20][10], temp[10]; int i, j, n; printf("Enter the number of Names you want to do input:n"); //how many names input scanf("%d", &n); printf("Enter names: n"); for (i = 0; i < n; i++) { scanf("%s", name[i]); strcpy(tname[i], name[i]); } //input names for (i = 0; i < n - 1 ; i++) { for (j = i + 1; j < n; j++) { if (strcmp(name[i], name[j]) > 0) { strcpy(temp, name[i]); strcpy(name[i], name[j]); strcpy(name[j], temp); } } } //for alphabetically sorting
  • 2. printf("n----------------------------------------n"); printf(" Input || NamestSorted namesn"); printf("------------------------------------------n"); for (i = 0; i < n; i++) { printf("%st || t%sn", tname[i], name[i]); //printf storted names } printf("------------------------------------------n"); } By Samsil Arefin [email protected]