title: Wait time returns minus value when arrival time is bigger than burst time in scheduling algorithm
body: <p>I am trying to implement FCFS scheduling algorithm in C and I created time intervals till the user enters another process. Here is the code following lines will show the actual question I want to ask.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  #define MAX 50
  
  struct ProcessControlBlock{
  
      int processID;
      int burstTime;
      int arrivalTime; 
      int turnAround;
  
  };
  
  void main(){
  
      int terminateController=1;
      int inputCheck;
      int processIndex = 0;
      struct ProcessControlBlock processControlBlocks[MAX];
      time_t beginTime = time(NULL);
      while(terminateController!=0){
  
  
          printf(&quot;If you want to enter a process, please press 1: &quot;);
          scanf(&quot;%d&quot;,&amp;inputCheck);
  
          time_t endTime = time(NULL);
          if(inputCheck==1){
              printf(&quot;The arrival time of the process is %d\n&quot;,(endTime-beginTime));
              processControlBlocks[processIndex].processID = processIndex;
              processControlBlocks[processIndex].arrivalTime = endTime-beginTime;
              printf(&quot;Process ID is: %d\n&quot;, processControlBlocks[processIndex].processID);
              printf(&quot;Enter the burst time of the process: &quot;);
              scanf(&quot;%d&quot;,&amp;processControlBlocks[processIndex].burstTime);
              printf(&quot;Waiting time of the process is: %d\n&quot;,(processControlBlocks[processIndex].burstTime-processControlBlocks[processIndex].arrivalTime));
          }
  
          printf(&quot;If you want to continue to add process, please press 1: &quot;);
          scanf(&quot;%d&quot;,&amp;terminateController);
          processIndex++;
      }
  
  }
  </code></pre>
  <p>So, for example, when the user waits for the second process entering, the time arrival will be let's say 12 seconds. And if the burst time of the process is 8 seconds, waiting time will be -4 seconds which does not make any sense. So, what is the mistake that I make or is there something that I miss?</p>