my sample code here - #include<iostream.h>
-
#include<conio.h>
-
#include<stdlib.h>
-
using namespace std;
-
-
struct process
-
{
-
int pn;
-
float at,bt,ct,tat,wt;
-
struct process *next;
-
}process;
-
////////////////////////////////////////////////////
-
-
float total_wait_time=0,total_turn_around_time=0;
-
int n;
-
process *get_process(float a,float b)
-
{
-
static int i=1;
-
pr=new(process);
-
pr->at=a,pr->bt=b;
-
pr->pn=i++;
-
pr->next=NULL;
-
return pr;
-
-
void insert(process *ptr,float a,float b)
-
{
-
process *pro,*temp;
-
pro=get_process(a,b);
-
while(ptr->next!=NULL)
-
{
-
temp=ptr;
-
ptr=ptr->next;
-
if(ptr->at>a);
-
{
-
pro->next=ptr;
-
temp->next=pro;
-
return;
-
}
-
}
-
ptr->next=pro;
-
}
-
void display(process *ptr)
-
{process *temp=ptr->next;
-
cout<<"Process\tArrival time\tBurst time\tCompletion time\tWaiting time\tTurn arround time\n";
-
while(temp!=NULL)
-
{
-
cout<<"P[%d]\t%3.2f\t\t%3.2f\t\t%3.2f\t\t%3.2f\t\t%3.2f\n",temp->pn,temp->at,temp->bt,temp->ct,temp->wt,temp->tat;
-
temp=temp->next;
-
}
-
cout<<"Average waiting time :%3.2f\nAverage turn arround time :%3.2f\n",total_wait_time/n,total_turn_around_time/n;
-
}
-
void ganttchart(process *ptr)
-
{
-
process *temp,*t;
-
temp=ptr->next;
-
t=ptr;
-
while(temp!=NULL)
-
{
-
temp->ct=t->ct+temp->bt;
-
t=temp;
-
temp=temp->next;
-
}
-
}
-
void wt_and_tat(process *ptr)
-
while(temp!=NULL)
-
{
-
temp->tat=temp->ct-temp->at;
-
total_turn_around_time+=temp->tat;
-
temp->wt=temp->tat-temp->bt;
-
total_wait_time+=temp->wt;
-
temp=temp->next;
-
}
-
}
-
////////////////////////////////////////////////////////////////
-
-
int main()
-
{
-
int i;
-
float a,b;
-
start=new(process);
-
start->next=NULL;
-
cout<<"=========FCFS Algo==========\nEnter the no. of process : ";
-
cin>>&n;
-
for(i=0;i<n;i++)
-
{
-
cout<<"Process P("<<i+1<<")\n";
-
cout<<"Arival time ?";
-
cin>>&b;
-
insert(start,a,b);
-
cout<<"\n";
-
ganttchart(start);
-
wt_and_tat(start);
-
display(start);
-
return 0;
-
}
-
-
-
.
In my code,
I am getting an error like this"error: excepted constructor, destructor, or type conversion before'*' token"
Please, help me out this to overcome this error.
5 1624
Mind showing more of your code?
I tried to run the code in CodeBlocks. It showed me tons of errors. Also, I couldn't find the one you asked for. Looks like you are implementing FCFS CPU scheduling algo. Maybe try to post the code after removing the basic syntax errors of curly braces and stuff.
- #include<stdio.h>
-
-
#include<stdlib.h>
-
-
typedef struct process
-
-
{
-
-
int pn;
-
-
float at,bt,ct,tat,wt;
-
-
struct process *next;
-
-
}process;
-
-
/////////////////////////////////////////
-
-
float total_wait_time=0,total_turn_around_time=0;
-
-
int n;
-
-
process *get_process(float a,float b)
-
-
{
-
-
static int i=1;
-
-
process *pr=(process *)malloc(sizeof(process));
-
-
pr->at=a,pr->bt=b;
-
-
pr->pn=i++;
-
-
pr->next=NULL;
-
-
return pr;
-
-
}
-
-
void insert(process *ptr,float a,float b)
-
-
{
-
-
process *pro,*temp;
-
-
pro=get_process(a,b);
-
-
while(ptr->next!=NULL)
-
-
{
-
-
temp=ptr;
-
-
ptr=ptr->next;
-
-
if(ptr->at>a)
-
-
{
-
-
pro->next=ptr;
-
-
temp->next=pro;
-
-
return;
-
-
}
-
-
}
-
-
ptr->next=pro;
-
-
}
-
-
void display(process *ptr)
-
-
{
-
-
process *temp=ptr->next;
-
-
printf("Process\tArrival time\tBurst time\tCompletion time\tWaiting time\tTurn arround time\n");
-
-
while(temp!=NULL)
-
-
{
-
-
printf("P[%d]\t%3.2f\t\t%3.2f\t\t%3.2f\t\t%3.2f\t\t%3.2f\n",temp->pn,temp->at,temp->bt,temp->ct,temp->wt,temp->tat);
-
-
temp=temp->next;
-
-
}
-
-
printf("Average waiting time :%3.2f\nAverage turn arround time :%3.2f\n",total_wait_time/n,total_turn_around_time/n);
-
-
}
-
-
void ganttchart(process *ptr)
-
-
{
-
-
process *temp,*t;
-
-
temp=ptr->next;
-
-
t=ptr;
-
-
while(temp!=NULL)
-
-
{
-
-
temp->ct=t->ct+temp->bt;
-
-
t=temp;
-
-
temp=temp->next;
-
-
}
-
-
}
-
-
void wt_and_tat(process *ptr)
-
-
{
-
-
process *temp=ptr->next;
-
-
while(temp!=NULL)
-
-
{
-
-
temp->tat=temp->ct-temp->at;
-
-
total_turn_around_time+=temp->tat;
-
-
temp->wt=temp->tat-temp->bt;
-
-
total_wait_time+=temp->wt;
-
-
temp=temp->next;
-
-
}
-
-
}
-
-
//////////////////////////////
-
-
int main()
-
-
{
-
-
int i;
-
-
float a,b;
-
-
process *START=(process *)malloc(sizeof(process));
-
-
START->next=NULL;
-
-
printf("=========FCFS Algo==========\nEnter the no. of process : ");
-
-
scanf("%d",&n);
-
-
for(i=0;i<n;i++)
-
-
{
-
-
printf("Process P(%d) \n",i+1);
-
-
printf("Arival time ? ");
-
-
scanf("%f",&a);
-
-
printf("Exicution time ? ");
-
-
scanf("%f",&b);
-
-
insert(START,a,b);
-
-
printf("\n");
-
-
}
-
-
ganttchart(START);
-
-
wt_and_tat(START);
-
-
display(START);
-
-
return 0;
-
-
}
-
-
Can U please change this to C++
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Innocence |
last post by:
Hi
I've been considering how to optimize map data structures for a tile
based Python game. However, since I'm a Python newbie I lack
experience with Pythons 'exotic' data types like lists and...
|
by: Chris Tanger |
last post by:
I am creating a class that has a method "Write" that I wish to make threadsafe. The method must block calling threads until the task performed in write is complete. Only 1 thread at a time can...
|
by: el_roachmeister |
last post by:
For being a good web programmer, is a course on data structures
important? It seems php already has built-in functions for what they
teach in a data structures course. On the other hand all...
|
by: John McCabe |
last post by:
Hi
I'm looking for something equivalent to the Data Structures and
Algorithms in Ada 95 books by Biedler and Feldman etc, but based
towards efficient C++ implementations.
Does anyone know of...
|
by: Martin Joergensen |
last post by:
Hi,
I wanted to try something which I think is a very good
exercise... I read in data from the keyboard and store them in a
structure. There's a pointer called "data_pointer" which I use to...
|
by: osp |
last post by:
hi to every one....
i just started out with c++ and i think i am
doing well.i use Robert Laffore to study. which book should i use for
data structures ? please help.
thank you
with regards
...
|
by: Mik0b0 |
last post by:
Hallo to everyone.
This fall I am going to start data structures as a part of C language
course. The problem is I could not find any satisfying tutorial about
structures in C. There are plenty of...
|
by: Joshua J. Kugler |
last post by:
A while back, I seem to remember coming across a small program that could
view and edit python data structures via a nice expanding tree view. I'm
now in need of something like that (to verify...
|
by: jehugaleahsa |
last post by:
Hello:
When developing data structures for C#, there is an obvious
performance hit when utilizing primitive types. For instance, a recent
hash table implementation I wrote works exceedingly fast...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |