Skip to main content

Bubble sort program by using pointers and functions in c

#include<stdio.h>
void swap(int *x, int *y)
{
int temp;
temp= *x;
*x=*y;
*y=temp;
}
int main()
{
int size,m,n;
printf("Enter size of array:");
scanf("%d",&size);
int a[size];
for(m=0;m<size;m++)
{
printf("Enter values of %d array element:",m);
scanf("%d",&a[m]);
}
for(m=0;m<size;m++)
{
for(n=m+1;n<size;n++)
{
if(a[m]>a[n])
{
swap(&a[m],&a[n]);
}
}
}
for(m=0;m<size;m++)
{
printf("%d\t",a[m]);
}
getch();
return 0;
}

Comments

Popular posts from this blog

Pre-requisites for development of a test & Characteristics of a good assessment (8638 02 3)

Question 03: What are pre-requisites for development of a test? What are characteristics of a good assessment? Answer: In education, the term assessment refers to the wide variety of methods or tools that educators use to evaluate, measure, and document the academic readiness, learning progress, skill acquisition, or educational needs of students. While  assessments are often equated with traditional tests-especially the standardized tests developed by testing companies and  administered to large populations of students-educators use a diverse array of assessment tools and methods to measure  everything from a four-year-old's readiness for kindergarten to a twelfth-grade student's comprehension of advanced  physics. Just as academic lessons have different functions, assessments are typically designed to measure specific elements  of learning-e.g., the level of knowledge a student already has about the concept or skill the teacher is planning to teach or  ...

Haier vs Gree Air Conditioners (T3- Technology): A Customer’s Honest Comparison After Using Both

  Feature Haier HSU-20 HFTEX Gree Airy GS-18AITH23S-T3 Price (PKR) 175,000 rupees                          235,000 rupees Cooling Gas R32 (A2L, flammable but more efficient) R410a (A1, safer but underperforms slightly) Cooling Performance Excellent – superior cooling Average – slightly underwhelming Material & Build Quality Decent Excellent – premium look and finish Airflow Direction Control Flexible – easy to direct airflow Limited – fins poorly designed, no airflow direction toward ground Safety Less safe due to flammable  gas Safer gas used Overall Experience Best for cooling Great aesthetics and features Conclusion (Based on Personal Use): Despite Gree's superior design, finishing, and safety, Haier outperforms it in cooling efficiency , which is ultimately what matters most in an air conditioner. If cooling is your top priority, Haier is the better choice .