FCFS with character invalid Any suggestion to improve this, they ask me to input characters that should be an invalid input and ask you again to input the number of process without crashing the program.

#include&lt;iostream&gt;
#include&lt;ctype.h&gt;
using namespace std;

int main()
{
     int bt[20],wt[20],avwt=0,i,j;
     int n;

     cout&lt;&lt;"Enter total number of processes(maximum 20):";
     cin&gt;&gt;n;
     while(char (n))
     {
          if(isalpha(n))
          {
                cout&lt;&lt;"Invalid Input";
          }


       cout&lt;&lt;"\nEnter Process Burst Time\n";
       for(i=0;i&lt;n;i++)
       {
            cout&lt;&lt;"P["&lt;&lt;i+1&lt;&lt;"]:";
            cin&gt;&gt;bt[i];
       }

       wt[0]=0;    
       for(i=1;i&lt;n;i++)
       {
             wt[i]=0+bt[i];
             for(j=0;j&lt;i;j++)
             wt[i]+=bt[j];
       }

        cout&lt;&lt;"\nProcess\t\tBurst Time\tArrival Time";

        for(i=0;i&lt;n;i++)
        {

             avwt+=wt[i];
             cout&lt;&lt;"\nP["&lt;&lt;i+1&lt;&lt;"]"&lt;&lt;"\t\t"&lt;&lt;bt[i]&lt;&lt;"\t\t"&lt;&lt;wt[i];
        } 

        avwt/=i;

        cout&lt;&lt;"\n\nAverage Waiting Time:"&lt;&lt;avwt;
    }
    return 0;
  }
Not sure exactly what this code is supposed to accomplish, but there are at least a few comments I think are valid regardless.

Avoid using namespace std;

This brings an extremely large number of names into scope. While perfectly reasonable with other namespaces, you usually want to avoid it with the std namespace.

Your use of isalpha

This code:

 cout&lt;&lt;"Enter total number of processes(maximum 20):";
 cin&gt;&gt;n;
 while(char (n))
 {
      if(isalpha(n))
      {
            cout&lt;&lt;"Invalid Input";
      }


... makes very little (if any) sense to me. You've read a number from the user, then you're trying to use isalpha on that. Since (in C and C++) char is a small integer type, it's valid (from the compiler's viewpoint) to pass that int to isalpha, but it's really not meaningful at all.

Given that you want a number less than or equal to 20, it would probably be best to check for that before using it though--as it stands now, if the user enters something like 30, the code will blithely continue trying to run, and write past the ends of the arrays it has allocated.

Use of arrays

That brings us to the next obvious problem: you're probably a lot better of using something like std::vector (or possibly std::array) rather than the arrays that are built into the language. These behave much better in general: they know their own size, don't decay to points the minute you look at them wrong, and are generally just a whole lot better.

Treat users humanely

Demanding that a user enter 20 (or even 10) process burst times interactively is inhumane. It would be much better to (for example) accept a file containing the burst times instead.

Use applicable standard algorithms

First of all, it looks to me like your computation of arrival times:

   wt[0]=0;    
   for(i=1;i&lt;n;i++)
   {
         wt[i]=0+bt[i];
         for(j=0;j&lt;i;j++)
         wt[i]+=bt[j];
   }


...is actually broken. Since you're storing the first arrival time as 0, you have a total of one more arrival time than burst times.

I'd switch to using std::vectors as mentioned previously, and then use the standard partial_sum algorithm to do most of the work:

wt[0] = 0;

std::partial_sum(bt.begin(), bt.end(), std::back_inserter(wt));


I believe this produces the results you wanted: for N inputs, it produces 0 for the first result, and each succeeding result is the sum of the burst times up to that point.

Names

Many of the names you've used (e.g., bt, wt, avwt) are (I suppose) quick to type, but certainly hard to read. I'd prefer to see burst_time, wait_time, average_wait, so I could read them a little more easily.

Output

Since you have one more arrival time than burst time, you may want to report your results a little differently. Right now, at least as I read things you're not reporting (or actually even computing) the last arrival time. Since the sequence is really that process 0 starts at time 0, and each successive time is based on the previous process times, I think I'd arrange the columns with the arrival time on the left and the process time on the right, so the numbers read more meaningful from let to right, top to bottom (i.e., in the direction people normally read).

For formatting output into columns, I'd also advise using std::setw instead of tabs.

Putting those together, we might end up with code something like this:

#include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;algorithm&gt;
#include &lt;vector&gt;
#include &lt;numeric&gt;
#include &lt;fstream&gt;
#include &lt;iomanip&gt;

int main(int argc, char **argv) {

    if (argc != 2) {
        std::cerr &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " &lt;filename&gt;\n";
        return EXIT_FAILURE;
    }

    std::ifstream in(argv[1]);

    // Read the burst times from the file into our vector:
    std::vector&lt;int&gt; burst_times{ std::istream_iterator&lt;int&gt;(in), {} };

    std::vector&lt;int&gt; arrival_times{ 0 };
    std::partial_sum(burst_times.begin(), burst_times.end(), 
                     std::back_inserter(arrival_times));

    int width = 10;
    std::cout &lt;&lt; "\n" &lt;&lt; std::setw(width) &lt;&lt; "Process" 
                      &lt;&lt; std::setw(width) &lt;&lt; "Arrival" 
                      &lt;&lt; std::setw(width) &lt;&lt; "Duration" &lt;&lt; "\n";

    int i;
    for (i = 0; i &lt; burst_times.size(); i++)
        std::cout &lt;&lt; std::setw(width) &lt;&lt; i + 1 
                  &lt;&lt; std::setw(width) &lt;&lt; arrival_times[i] 
                  &lt;&lt; std::setw(width) &lt;&lt; burst_times[i] &lt;&lt; "\n";

    std::cout &lt;&lt; std::setw(width) &lt;&lt; i + 1 
              &lt;&lt; std::setw(width) &lt;&lt; arrival_times[i] &lt;&lt; "\n";

    auto total_times = std::accumulate(arrival_times.begin(), arrival_times.end(), 0);
    auto average_time =  total_times / arrival_times.size();

    std::cout &lt;&lt; "\n\nAverage Waiting Time: " &lt;&lt; average_time &lt;&lt; "\n";
}