Answer:
/* Frame sorting using bubble sort */ // By Sandeep
#include<stdio.h>
#include<conio.h>
//defining frame structure
struct frame
{
int frameno;
char msg[90];
};
void main()
{
struct frame temp;
struct frame v[10];
int n,i,j; // required variables
clrscr();
printf("enter the number of frames\n");
scanf("%d",&n); // read number of frames
printf("enter the frameno and messages\n");
// read frames
for(i=0;i<n;i++)
{
printf("\n frame no:\t");
scanf("%d",&v[i].frameno);
printf("\tMessage:");
scanf("%s",v[i].msg);
}
//Bubble sort technique is using to sort frames here just the address of
//v[j] getting changed
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(v[j].frameno>v[j+1].frameno)
{
temp=v[j];
v[j]=v[j+1];
v[j+1]=temp;
}
}
}
// prints the sorted frames
printf("sorted frames are\n");
for(i=0;i<n;i++)
printf("%d\t%s\n",v[i].frameno,v[i].msg);
getch();
}
/*
By Sandeep G
Gousia college of enineering
Information Science
for queries,comments : crazzy.sandeep@gmail.com
sandeepg4284@gmail.com
hi friends, those who are satisfied with this program or got help from tis -"pls post ur comments to mail id above mentioned and queries about the program"
*/