The following code shows a C Program to Perform Sorting Using Bubble Sort.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int i, j, total, size, t, finished=1;
int arr[10]={12, 90, 11, 89, 67, 55, 79, 18, 60, 49};
int *myarr=arr;
for(i=0;i<9;i++)
{
for(j=0;j<9-i;j++)
{
if(*(myarr+j) > *(myarr+j+1)){
t=*(myarr+j);
*(myarr+j)=*(myarr+j+1);
*(myarr+j+1)=t;
finished=0;
}
}
if(finished)
break;
}
for(i=0;i<10;i++)
printf("%d ", *(myarr+i));
return 0;
}
Output
11 12 18 49 55 60 67 79 89 90
Further Reading
50+ C Programming Interview Questions and Answers
C Program to Find Factorial of a Number
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML