Thursday, 24 April 2014

WAP to Sort the given N-frames in priority order

#include<conio.h>
int main()
{
    int i,j,SizeOfInput,FrameNumber[20],temp;
    char FramaName[25];
    char temp1;
    printf("----------------------- Sorting N frames -------------------\n:");
    printf("enter the size of input\n:");
    scanf("%d",&SizeOfInput);
    printf("enter the %d input frames\n",SizeOfInput);
   
    for(i=0;i<SizeOfInput;i++)
    {
                               scanf("%s",&FramaName[i]);
    }
   
     printf("enter the %d frames numbers \n",SizeOfInput);
      for(i=0;i<SizeOfInput;i++)
    {
                               scanf("%d",&FrameNumber[i]);
    }
    for(i=0;i<SizeOfInput-1;i++)
    {
                              for(j=i+1;j<SizeOfInput;j++)
                              {
                                                        if(FrameNumber[i]>FrameNumber[j])
                                                        {
                                                                   temp=FrameNumber[i];
                                                                   FrameNumber[i]= FrameNumber[j];
                                                                   FrameNumber[j]=temp;
                                                                   temp1= FramaName[i];
                                                                   FramaName[i]=FramaName[j];
                                                                   FramaName[j]=temp1;                   
                                                        }
                              }
    }
     for(i=0;i<SizeOfInput;i++)
     {
                               printf("%c \t",FramaName[i]);
                               printf("%d \n",FrameNumber[i]);
     }
                              
    getch();

}

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2016