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


   #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-

Related Posts Plugin for WordPress, Blogger...
Related Posts Plugin for WordPress, Blogger...
 

Most Reading

Labels