{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

e6 - printf"\nHIT RATIO.2f",h/n void main int...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> /* RISHI AGARWAL      FIFO REPLACEMENT ALGO    ROLL NO 02        SE CMPN A */ void disp(int z[],int x) {  int i;  printf("\n");  for(i=0;i<x;i++)   if(z[i]!=-1)    printf("%d ",z[i]); } void fifo(int a[],int n,int x) {  int i=0,j=0,z[5],q=0;  float h;  for(i=0;i<x;i++)   z[i]=-1;  i=0;  for(j=0;j<n;j++)   {    if(i==x)     i=0;    if(a[j]!=z[0]&&a[j]!=z[1]&&a[j]!=z[2])    {     z[i]=a[j];     i++;     disp(z,x);    }    else    {disp(z,x);     printf("\tHIT");     q++;}   }  h=q;  printf("\nTOTAL no of hits %d",q);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf("\nHIT RATIO : %.2f",h/n); } void main() { int i,x,n,a[20]; clrscr(); printf("Enter the no of pages & index"); scanf("%d%d",&n,&x); printf("Enter the page nos"); for(i=0;i<n;i++) scanf("%d",&a[i]); fifo(a,n,x); getch(); } OUTPUT: Enter the no of pages & index12 3 Enter the page nos2 3 2 1 5 2 4 5 3 2 5 2 2 2 3 2 3 HIT 2 3 1 5 3 1 5 2 1 5 2 4 5 2 4 HIT 3 2 4 3 2 4 HIT 3 5 4 3 5 2 TOTAL no of hits 3 HIT RATIO : 0.25...
View Full Document

{[ snackBarMessage ]}