In operating systems, tasks that are queued to be processed go through different scheduling algorithms in different operating systems. Priority Scheduling is one of them.
Priority scheduling is like shortest job first except that the next job to process is selected not by the amount of time it will take, but by the priority of the job. So in this priority scheduling each job has a priority value associated with it. The task with shortest priority value gets preferred.
However, I explained priority scheduling in my another post earlier and as many of my readers wanted to have the source code, here I am publishing the source code of the program. I am not currently explaining the source code, please try to play with it to understand it. I am removing comments intentionally.
Following is a screenshot of the program with input and output.
I hope that you can now study and experiment the source code to write yours and that would be much better, more efficient and strict than this one.