Skip to content

Instantly share code, notes, and snippets.

@michaelsilver
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelsilver/6f2635b525633e65a881 to your computer and use it in GitHub Desktop.
Save michaelsilver/6f2635b525633e65a881 to your computer and use it in GitHub Desktop.
Looping for Letters: print to sd-out "letter:number" where letters loop a-z, and numbers increase 0 thru infinity
#include <iostream>
using namespace std;
int MAX = 100;
int main() {
for(int i=0; i<MAX; i++){
cout << char('a'+ (i % 26)) << ':' << i << endl;
// the percent sign is the "modulus," meaning it gives you the
// remainder when you devide two things: e.g. 26 % 5 = 1 because
// the remainder when you divide 26 by 5 is 1.
}
return 0;
}
a:0
b:1
c:2
d:3
e:4
f:5
g:6
h:7
i:8
j:9
k:10
l:11
m:12
n:13
o:14
p:15
q:16
r:17
s:18
t:19
u:20
v:21
w:22
x:23
y:24
z:25
a:26
b:27
c:28
d:29
e:30
f:31
g:32
h:33
i:34
j:35
k:36
l:37
m:38
n:39
o:40
p:41
q:42
r:43
s:44
t:45
u:46
v:47
w:48
x:49
y:50
z:51
a:52
b:53
c:54
d:55
e:56
f:57
g:58
h:59
i:60
j:61
k:62
l:63
m:64
n:65
o:66
p:67
q:68
r:69
s:70
t:71
u:72
v:73
w:74
x:75
y:76
z:77
a:78
b:79
c:80
d:81
e:82
f:83
g:84
h:85
i:86
j:87
k:88
l:89
m:90
n:91
o:92
p:93
q:94
r:95
s:96
t:97
u:98
v:99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment