Write C/C++ program to implement TDM


Aim :- Write C/C++ program to implement TDM.


C Program Code :


#include <stdio.h>
#include <conio.h>

void main()
{
 int a[4],time=120;
   int u1,u2,u3,u4,i;
   clrscr();
   printf("Enter Time of Each User : ");
   for(i=0;i<4;i++)
   {
     printf("\na[%d] : ",i+1);
     scanf("%d",&a[i]);
   }
   u1=a[0]/10;
 u2=a[1]/10;
 u3=a[2]/10;
 u4=a[3]/10;
 while(time!=0)
 {
     if(u1>0)
     {
      printf("\nUser[1] Using Channel.");
      time=time-10;
      u1=u1-1;
     }
     if(u2>0)
     {
      printf("\nUser[2] Using Channel.");
      time=time-10;
      u2=u2-1;
     }
     if(u3>0)
     {
      printf("\nUser[3] Using Channel.");
      time=time-10;
      u3=u3-1;
     }
     if(u4>0)
     {
      printf("\nUser[4] Using Channel.");
      time=time-10;
      u4=u4-1;
     }
   }
 getch();
}


Output :


Post a Comment

0 Comments