Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need to confirm

Posted on 1999-07-09
23
Medium Priority
?
201 Views
Last Modified: 2010-04-15
I just did this problem also...

I want the contents of the queue Q after the first loop, then I want the output of the following code..

int i, n;
typedef int queueItemType;
queueClass Q;
for(i=1;i<=5; i++)
Q.QueueAdd(i, Success);
for(i=1;i<=5;i++0
{
Q.GetQueueFront(n, Success);
Q.QueueRemove(Success);
cout<<n;
}
cout<<endl;
0
Comment
Question by:netminder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 4
  • +4
23 Comments
 
LVL 3

Expert Comment

by:Shay050799
ID: 1263459
what ?#$@#$%$##
is this english or what ?

explain...
0
 

Author Comment

by:netminder
ID: 1263460
Basically I was looking for the output created after the first loop of the program. Then I wanted the ouput at the end of the program.
0
 
LVL 5

Expert Comment

by:yonat
ID: 1263461
This seems like homework. According to the EE customers agreement we can't do your homework for you.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:netminder
ID: 1263462
Homework it isn't. I have a learn c/c++ book I borrowed from
my library. The only unfortanate thing is that somebody needed to take out the answer section.
0
 
LVL 3

Expert Comment

by:Shay050799
ID: 1263463
dear netminder yonat is joking with you don't worry.
and yonat what are u doing online friday night ? huh
go to a Tel Aviv Pub or something :-)

Netminder give me a minute
0
 
LVL 3

Expert Comment

by:Shay050799
ID: 1263464
we need more code of it... what is success ?
0
 
LVL 2

Expert Comment

by:helver
ID: 1263465
Without knowing exactly what this queueClass does (I have no idea what Success is, where it defined, or what purpose it serves), I would guess that after the first loop, Q would contain the integers: [ 1,2,3,4,5 ].

I would also guess, again, not knowing anything about these functions except their names, that the output of the code would be:

12345

And this is C++.
0
 
LVL 3

Expert Comment

by:Shay050799
ID: 1263466
the code is mixed up according to the little program the output is:
55555 cause the second loop is i not n
0
 
LVL 5

Expert Comment

by:yonat
ID: 1263467
netminder, sorry for assuming it was homework - it just looked this way.

Shay,
> yonat what are u doing online friday night ? huh
> go to a Tel Aviv Pub or something :-)

That would be difficult, since I live near Qiryat Shemona...
0
 
LVL 3

Expert Comment

by:Shay050799
ID: 1263468
yonat:
really ? where ?

0
 

Author Comment

by:netminder
ID: 1263469
As far As I can tell Success just confirms that the operation was succesful. As for giving more code, that's it. I probably could have borrowed a better book. Thanks for all the help though.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1263470
Q.GetQueueFront(&n, Success);
0
 
LVL 5

Expert Comment

by:yonat
ID: 1263471
Hi Shay,
I live in Kibutz Maayan Baruch. BTW, you can mail me at yonat@usa.net (so netminder will not have to read through our boring comments...)
0
 
LVL 3

Expert Comment

by:arnond
ID: 1263472
Shay, do you happen to live in Tel-Aviv or somewhere around Tel-Aviv ?

Arnon David.
(sarnon@t2.technion.ac.il)
0
 

Author Comment

by:netminder
ID: 1263473
Ahoffmann's,

I appreciate your response, but I was lokking for the numerical output.

Thanks anyway
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1263474
what do you mean by "numerical output"?
Your posted code can't do it right, 'cause of the value parameter (except you have a sophisticated compiler ;-)
0
 
LVL 3

Accepted Solution

by:
Laminamia063099 earned 300 total points
ID: 1263475
The queue contents after the first loop are:
  First entered-> 1 2 3 4 5 <-last entered

The output, because this is a queue, GetQueueFront interrogates the value of the oldest, or first entered, member of the queue.  This value is places in n.  Success is whether or not it succeeded, ie, whether or not there was a value at the front of the queue.  Remove, then, if the GetQueueFront was successful, removes the first member of the queue.  Your output is:
  1 2 3 4 5  
Or, the queue contents after each remove:
  1 2 3 4 5 //before first remove
  2 3 4 5   //after removing 1
  3 4 5     //after removing 2
  4 5       //...
  5         //...

Just a Note:  if the book doesn't explain it well, a queue if FIFO->First in, First out.  It's like standing in a line.  The first one in the line is the first one out.  You can't get out until everyone in front of you has gone.  

Good luck learning C/C++.  Ask any more questions you desire :)
0
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 1263476
Note: The queue contents after each remove is NOT output to the screen.  I just added them to show you how the queue looks before and during the second loop.

Laminamia
0
 
LVL 2

Expert Comment

by:helver
ID: 1263477
Laminamia, if we were doing a cout<<Q, then I would agree with you.  But that doesn't appear to be what's happening.  n is an int, as such it could not be a Queue unless the GetQueueFront function did some strange casting.

0
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 1263478
Sorry I was confusing.  The output that I have written is the integer n that is removed from the queue each time.  The queue contents that I included were to clarify what was happening to the queue, not as part of the cout output.  

The output of this program is:
1    2     3     4     5

There is no endl with each cout, and each cout outputs the front-most member of the queue that was interrogated and removed in the loop.
 
I hope this clarifies my answer.
0
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 1263479
I see where my answer sounds confusing.  The oldest member of the queue, or the frontmost integer in the queue is interrogated with GetQueueFront.  NOTE:
>>1 2 3 4 5
>>2 3 4 5
>>3 4 5
>>4 5
>>5
This is only the queue contents during the loop.  This is not output to the screen.  I included it to help out netminder.  

Laminamia :)
0
 
LVL 2

Expert Comment

by:helver
ID: 1263480
*smile*  If you'll look at my first comment, I think you'll see that I agree 100%.
0
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 1263481
(: Oops :)
(Sometimes I miss some of the comments when there are so many).

Laminamia
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question