473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

FCFS algorithm C++ program please help!

Hi to all,
im just a newbie here..
can someone help me with my program about FCFS scheduling algo,
here the code that i made..
the first 2 process is correct but the succeding process is not.. please help me with the right computation.

note: TAT= Time of completion - Arrival Time;
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. int proc,x,at[10],bt[10],sum;
  5. main()
  6. {
  7. clrscr();
  8.  
  9. printf ("Input number of process: ");
  10. scanf("%d",&proc);
  11.  
  12. printf ("\n\nProcess#\t\tArrival Time\t\tBurst Time\tTat");
  13.  
  14. for (x=1;x<=proc;x++)
  15. {
  16. gotoxy (4,4+x);
  17. printf("%d",x);
  18.  
  19.  
  20. gotoxy (30,4+x);
  21. scanf ("%d", &at[x]);
  22.  
  23. gotoxy (55,4+x);
  24. scanf("%d",&bt[x]);
  25.  
  26. sum=sum+1+bt[x]-at[x];
  27.  
  28. gotoxy (65,4+x);
  29. printf("%d",sum);
  30. }
  31. getch();
  32.  
  33. return 0;
  34. }
  35.  
Thanks a lot!
Feb 10 '08 #1
1 12652
Read Arrival Time and Burst Time for all Process
Let WaitingTime[0] = 0 and TAT[0]=BurstTime[0]
WaitingTime[i]=TAT[i-1]-ArrivalTime[i]
TAT[i]=BurstTime[i]+WaitingTime[i]
Feb 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: abs | last post by:
Here's my page containing problematic alghoritm which seems to be easy but I have some problems with it: http://tinyurl.com/a2v58 The trouble is that when I click on element which has yellow...
34
by: John Harrison | last post by:
An odd confession; an odd request; but here's the tale.... My company has a few PC systems which we have used for about 7 years and not updated - we've "made do", and besides, "if it ain't...
5
by: Nikola | last post by:
I need to write a program that generates 5 random numbers and puts them into a linked list. (Print the list) From that list it forms another list in a way if the arrangement of elements in the...
2
by: ben | last post by:
hello, i'm following an algorithm book and am stuck on an early excersise in it, not because of the c programming side of it or even the algorithm side of it, i don't think, but because of maths....
9
by: kwindham | last post by:
This program doesn't seem like it should be too hard, but I cannot figure it out. Here is the assignment: Password Verifier - Write a program to verify passwords, satisfying the following...
0
by: maleman2003 | last post by:
I would like to know if anyone would have a reference where I can browse to and review Code for a Genetic Algorithm that maximize value of f(x,y) and the values of x and y. This algorithm is to...
8
by: [rob desbois] | last post by:
I've not really used sequence algorithms before and am having some trouble interpreting usage from The C++ Programming Language . The effect I'd like to achieve is to copy all entries (key and...
3
by: deepan | last post by:
Hai everybody! I've recently joined this group.Really amazed at the activity of this group! Please somebody could suggest me a c code to search for the no. in a given array of no.s without...
4
by: slapsh0t11 | last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment: Here is my class file...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.