Solved

simple question

Posted on 1998-12-15
2
154 Views
Last Modified: 2010-04-02
I have a for loop that counts to a given number.
I have to stop at every time the count reaches 12.
12,24 ,36 etc.
for(int i=0;i<count;i++)
{
 if(i==12)
  {
  cout<<"test"; //this is what started out with.
  }
}
Please help.
Thank you
0
Comment
Question by:strmtrpr
2 Comments
 

Accepted Solution

by:
vmehro earned 20 total points
ID: 1180259
if (i%12 == 0) will take care of 12 and multiples of 12.


0
 

Author Comment

by:strmtrpr
ID: 1180260
Thank you very much.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now