e6 - printf("\nHIT RATIO :...

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;    {     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 DocumentRight 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(&quot;\nHIT RATIO : %.2f&quot;,h/n); } void main() { int i,x,n,a[20]; clrscr(); printf(&quot;Enter the no of pages &amp; index&quot;); scanf(&quot;%d%d&quot;,&amp;n,&amp;x); printf(&quot;Enter the page nos&quot;); for(i=0;i&lt;n;i++) scanf(&quot;%d&quot;,&amp;a[i]); fifo(a,n,x); getch(); } OUTPUT: Enter the no of pages &amp; 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

Page1 / 2

e6 - printf(&amp;amp;quot;\nHIT RATIO :...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online