Hi,
I have a problem about nested loops in c#. I think this forum is about c and c++. But at least you may write its algorithm. The problem is to print :
1 2 3
2 3 4
3 4 5
4 5 6
Thanks a lot.
Printable View
Hi,
I have a problem about nested loops in c#. I think this forum is about c and c++. But at least you may write its algorithm. The problem is to print :
1 2 3
2 3 4
3 4 5
4 5 6
Thanks a lot.
Take a look at this program(Assuming That N is 5). It may help you. Btw, my suggestion would be if you can't write such easy programs you should learn C first. Directly jumping to C# is not a good idea
Code:#include <stdio.h>
#define N 5
int main(void)
{
int i,j,k;
for(i=1;i<=N;i++)
{
k=i;
for(j=1;j<=3;j++)
printf("%d ",k++);
printf("\n");
}
return 0;
}
Thank you.
I know it is an easy one but numbers confuse my mind. I can make any shape with stars about nested loops :D . I will make more examples about them. Thank you again.