#include<stdio.h> int main() { int i,j,n,a[50],frame[10],no,k,avail,count=0; printf("Enter the no of pages: "); scanf("%d",&n); printf("Enter the page no: "); for(i=1;i<=n;i++) scanf("%d",&a[i]); printf("Enter the no of page frames: "); scanf("%d",&no); for(i=0;i<no;i++) frame[i]= -1; j=0; printf("\tPAGE NO\t PAGE FRAMES\n"); for(i=1;i<=n;i++) { printf("%d\t\t",a[i]); avail=0; for(k=0;k<no;k++) if(frame[k]==a[i]) avail=1; if (avail==0) { frame[j]=a[i]; j=(j+1)%no; count++; for(k=0;k<no;k++) printf("%d\t",frame[k]); } printf("\n"); } printf("Page Fault Is %d",count); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter