Increasing Integer

Hey guys, would any of you know how to make a integer increase by 1 every 2 seconds? Then have it start over at 50?
Yes.
Thank you I completely understand now
We're glad. For a moment we thought you might ask a specific question about creating a specific solution to this problem.


If you want an answer to a different question than you ask, then you must ask the correct question to begin with. Programmers, alas, can be very literal.


Please tell us more about what you are trying to do and on what OS.
Last edited on
Very easy!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
int i = 0;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i++;
sleep(2000);
i = 0;


Ciao, Imi.

PS: Reminds me of a joke: In an airline company, the pilot use to fill out an error report card when something was wrong during the flight. The tech-guy then get the card, fix it and write his report below. Someone posted some funny cards. One of them was:

Pilot: "Something is rattling."
Tech: "Solved. Tighten something."
@walapu
do you want to make some kind of a timer? (for a game perhaps?) do you want to call any functions depending on the value of i in every period (i=0->50)? maybe multithreading is a solution to your problem (if you want the timer to run in the background, in parallel with your main program), but maybe not... what exactly is it that you want to do?
Last edited on
That wasn't funny, firedraco... *bursts out laughing*

Seriously, though, have you checked our constitution lately?
We the geeks of the C++ forum, in Order to establish a less ambiguous Forum, establish Assistance, insure against Segmentation Faults, provide for common Reference, promote the use of For Loops, secure the Blessings of our Compilers to ourselves and our Computers, do ordain and establish this Constitution for the C++ Forum.


Skip a bit...

The admin shall make no law respecting an establishment of inambiguity, or prohibiting the free exercise thereof; or abridging the freedom of answering the exact question given, or of posting; or the right of the people peaceably to assemble their assembly code, and to petition the Elite for a redress of their compiler errors.


And...

No person shall be held to answer a capital, or otherwise infamous question, unless on a presentment or indictment of the Admin, except in cases arising in the server or the IRC, or among the Elite, when in actual service in time of Hacking or public danger; nor shall any person be subject to answer the same question twice and to be twice put in jeopardy of wasting time; nor shall be compelled in any case to be an answerer of his own question, nor be deprived of life, liberty, or forum rights, without due process; nor shall publicly-made property be taken for exclusively private use, without just compensation.


-George Albatross
Last edited on
Topic archived. No new replies allowed.