Round Robin CPU Scheduling - C Program
#include <stdio.h>

int main()
{
    int bt[10], rem[10], wt[10], tat[10];
    int n, tq;
    int i;
    int time = 0;
    int completed = 0;

    printf("Enter number of processes: ");
    scanf("%d", &n);

    printf("Enter Burst Time:\n");

    for (i = 0; i < n; i++)
    {
        printf("P%d: ", i + 1);
        scanf("%d", &bt[i]);

        rem[i] = bt[i];
        wt[i] = 0;
        tat[i] = 0;
    }

    printf("Enter Time Quantum: ");
    scanf("%d", &tq);

    while (completed < n)
    {
        for (i = 0; i < n; i++)
        {
            if (rem[i] > 0)
            {
                if (rem[i] <= tq)
                {
                    time += rem[i];
                    rem[i] = 0;

                    completed++;

                    tat[i] = time;
                    wt[i] = tat[i] - bt[i];
                }
                else
                {
                    time += tq;
                    rem[i] -= tq;
                }
            }
        }
    }

    printf("\nProcess\tBT\tWT\tTAT\n");

    for (i = 0; i < n; i++)
    {
        printf("P%d\t%d\t%d\t%d\n",
               i + 1, bt[i], wt[i], tat[i]);
    }

    return 0;
}