Loop Control Statements 145
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
81 82 83
84
85
86 87
88 89
91
92
93
94 95
96
97 98 99 100
Explanation The first for loop is varying from 48 to 57. These numbers are used for printing first
digit of every number from 1 to 1Q0. 48 to 57 are ASCII codes for 0 to 9. The second for loop is
varying from ASCII 49 to 57 whose equivalent numerical numbers are 1 to 9. These ASCII codes are
used for printing second digit. In each output line the common digit like 0 in the first line is decided
by variable of the outer loop. It varies from 0 to9. The second digit of each line is decided by the
variable of inner loop, which varies for all lines from 1 to 9. The value of k =-9 for displaying 10
rows. For displaying numbers from 01 to 99 i & j are printed without using space in oneprint f ()
statement.
The first i f statement is used for printing 10,20,30 upto 90 numbers. The second i f is used to
print 100.
6.311 Write a program to count number of votes secured by 'A' & 'B Assume three voters
are voting them. Also count the invalid votes.
# include <stdio.h>
# include <conio.h>
# include <ctype.h>
void xnain()
{
int a * 0 ,b a 0 ,o « 0,i;
char v;
c l r s c r () ;
printf (" Press A or Bn");
fo r (i=l/i’<=3/*i++>
{
printf ("nnVoter no. %d”,i);
printf (" Enter Vote
v=getche();
v=toupper(v);
if (v=='A')
a++;
else if ( v ~ ’Br)
b++;
else
o++;
/