Thursday, April 7, 2016

White a loop to display number like this format?

3
6
12
15
18
21
24
27
30

Method 1:

 for(int i=3; i<31; i+=3)
Console.WriteLine(i);

Method 2:

 int i, j;
for(i=1; i <=10; a++)
{  j=3*i;
Console.WriteLine(j); }

Method 3:

int i=1;
while(i<11)
{ Console.WriteLine(i*3);
i +=1; }


No comments:

Post a Comment