CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

Couting the attempts in a 'while' loop? topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2010, 02:15 PM
Junior Member
 
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
HannahMar is on a distinguished road
| More
Couting the attempts in a 'while' loop?

Hi there, I am VERY new to programming and I was wondering if there was a way to count the attempts it took a user to guess a correct number (in a while loop) and then display that number back to the console?
Reply With Quote
  #2  
Old 04-17-2010, 04:21 AM
Junior Member
 
Join Date: Apr 2010
Posts: 10
Thanks: 0
Thanked 3 Times in 3 Posts
servalsoft is on a distinguished road
| More
Re: Couting the attempts in a 'while' loop?

Quote:
Originally Posted by HannahMar View Post
Hi there, I am VERY new to programming and I was wondering if there was a way to count the attempts it took a user to guess a correct number (in a while loop) and then display that number back to the console?
int count = 0;
while (condition)
{
//do something
++count; //this line increase the count every time the loop is called
}
Reply With Quote
The Following User Says Thank You to servalsoft For This Useful Post:
coderzone (11-27-2010)
  #3  
Old 04-17-2010, 05:52 AM
pankaj.sea's Avatar
Super Moderator
 
Join Date: Sep 2009
Location: Serampore
Posts: 132
Thanks: 0
Thanked 2 Times in 2 Posts
pankaj.sea is on a distinguished road
| More
Re: Couting the attempts in a 'while' loop?

++count or count++ is depends on what of calculation or logic you are coding!
because they works in different way!
Reply With Quote
  #4  
Old 04-17-2010, 04:54 PM
Junior Member
 
Join Date: Apr 2010
Posts: 10
Thanks: 0
Thanked 3 Times in 3 Posts
servalsoft is on a distinguished road
| More
Re: Couting the attempts in a 'while' loop?

That's right unless neccessary, I usually used pre-increment, ++count; because it performs less calculations hence it is much faster....
Reply With Quote
The Following User Says Thank You to servalsoft For This Useful Post:
coderzone (11-27-2010)
  #5  
Old 11-23-2010, 10:33 AM
Junior Member
 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sai111 is on a distinguished road
| More
Re: Couting the attempts in a 'while' loop?

tankhuuuuuuuuuuu
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Do While loop syntax codeunlock C# Programming 1 04-29-2007 08:31 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 04:37 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board