C PROGRAM TO IMPLEMENT EDGE CHASING DEADLOCK DETECTION ALGORITHM

Saturday, 7 January 2017


#include<stdio.h>
#include<conio.h>
void main()
{
 int d[7][7];
 int i,j,n,a;
 int res;
 clrscr();
 printf("Enter the number of nodes\n\n");
 scanf("%d",&n);
 printf("Enter the elements of Dependency matrix");
 for(i=0;i<n;i++)
 {
   for(j=0;j<n;j++)
   {
  scanf("%d",&d[i][j]);
   }
  }
  d[0][1]=1;
  d[1][2]=1;
  d[2][3]=1;
printf("DEPENDECNY MATRIS IS:\n");
 for(i=0;i<n;i++)
 { for(j=0;j<n;j++)
  {
 printf("%d",d[i][j]);
  }
 }
  getch();
}

OUTPUT-



C PROGRAM TO IMPLEMENT HAUNG’S TERMINATION DETECTION

Saturday, 7 January 2017


#include<stdio.h>
#include<conio.h>
void main()
{
 double p[3];
 double c=1;
 int k,j,res,res1,i,now,now1,con;
 clrscr();
 for(i=0;i<3;i++)
 {
  p[i]=0;
 }
 printf("\nWhich process do you want to start?\n");
 k=0;
 printf("p[%d] OR p[%d] OR p[%d]",k,k+1,k+2);
 printf("\nenter the process no.(0/1/2):\n");
 scanf("%d",&j);
 p[j]=0.5;
 c=c-p[j];
 printf("\nDoes process C(controller)invokes any other process:\nFor Yes-Press 1\nFor No-press 0\n");
 scanf("%d",&res);
 if(res==1)
 {
  printf("\nWhich process will it invoke(1 OR 2):\n");
  scanf("%d",&now);
  p[now]=0.25;
  c=c-0.25;
 }
 printf("\nDoes process C(controller)invokes any other process:\nFor Yes-Press 1\nFor No-press 0\n");
 scanf("%d",&res1);
 if(res1==1)
 {
  printf("\nWill it invoke(1 OR 2):\n");
  p[now1]=0.25;
  c=c-0.25;
 }
 for(i=0;i<3;i++)
 {
  printf("\nIs Process p[%d] is completed:?\nfor yes-press 1\nfor No-press 0\n",i);
  scanf("%d",&con);
  if(con==1)
  {
   c=c+p[i];
  }
 }
 if(c==1)
 {
  printf("\nAll Processes are COMPLETED");
 }
 else
 {
  printf("\nSome PROCESS is NOT Complete");
 }
 getch();    


  }

OUTPUT-



Decimal to Binary Conversion C Program

Saturday, 7 January 2017


   #include<stdio.h>
   #include<conio.h>
   void main()
   {
   int a[10],n,i;
   clrscr();
   printf("Enter no.\n");
   scanf("%d",&n);
   for(i=0;n>0;i++)
   {
   a[i]=n%2;
   n=n/2;

   }
   printf("Binary:\n");

   for(i=i-1;i>=0;i--)
   {
   printf("%d",a[i]);
   }
   getch();
   }

OUTPUT-

Analog Clock C program to find Mirror Image Clock Time

Saturday, 7 January 2017

If you want to find Mirror watch time then put input as your real watch time and in output you can find mirror image watch time.


#include<stdio.h>
#include<conio.h>
void main()
{
int h,m,s;
clrscr();
printf("Enter Hour: ");
scanf("%d",&h);
printf("Enter Min:");
scanf("%d",&m);
printf("Enter Second:");
scanf("%d",&s);
if(h>12||m>60||m>60)
{
printf("\nEnter correct time:\n");
}
printf("Mirror Time:\n");
if(h>=1&&h<=12&&m>=1)
{
h=12-h-1;
printf("%d",h);
}
else if(h>=1&&h<=12&&m==0)
{
h=12-h;
printf("%d",h);
}
if(m>=1&&m<=60)
{
m=60-m;
printf(":%d",m);
}
else if(m==0)
printf(":%d",m) ;
if(s>=1&&s<=60)
{
s=60-s;
printf(":%d",s);
}
else if(s==0)
printf(":%d",s) ;
getch();
}


OUTPUT-



Page 1 of 14123...14
Related Posts Plugin for WordPress, Blogger...
Related Posts Plugin for WordPress, Blogger...
 

Most Reading

Labels