Click here to Skip to main content
14,697,191 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
am enetring a value to a text box
eg: 4 ( only 1-9 digits)

i want to use this value as the upper bound
for creating

if i give 4 means want structure like as follows
for adding t a list in this order
12,13,23
14,24,34


5 means

12,13,23,
14,24,34
15,25,35,45
Posted
Updated 24-Jan-13 0:12am
v3
Comments
Sushil Mate 24-Jan-13 4:31am
   
school assignment?
Faisalabadians 24-Jan-13 4:37am
   
yeh, I thing so :)
PIEBALDconsult 24-Jan-13 4:39am
   
Looks like combinations of { 1 , 2 , 3 , 4 } taken two at a time. There are several relevent articles here; one is mine. But you won't learn if you don't figure it out yourself. You learn from the journey; not the destination.
P_Dash 24-Jan-13 4:50am
   
These are basic level questions.
If you can't do this on your own, How can you come to learn programming ??
These are the basics of any programming language.

So think & try by yourself & I know you will crack it.

1 solution

'C' Language
int s = 12;
int i,j;
for(i=3;i>=1;i--)
{ 
   for( j=s; j<s+i; j++)  
   {
      printf("%d",j);
   }
   s = s+11;
   printf("\n");
}


'C#' Language

class Program
    {
        static void Main(string[] args)
        {
            int s = 12;
            int i,j;
            for(i=3;i>=1;i--)
            {
               for( j=s; j<s+i; j++)
               {
                  Console.Write(j.ToString());
               }
               s = s+11;
               Console.Write("\n");
            }
            Console.Read();
        }
    }
   
v5
Comments
PIEBALDconsult 24-Jan-13 4:58am
   
I'm hoping that won't compile.
Azziet 24-Jan-13 5:02am
   
why? check this in your c editor
Faisalabadians 24-Jan-13 5:04am
   
PIEBALDconsult you are hoping exactly right... inner for loop has syntax error
PIEBALDconsult 24-Jan-13 5:06am
   
Have you checked it in yours?
Azziet 24-Jan-13 5:07am
   
that was just typing error...i've improved the solution
Azziet 24-Jan-13 5:07am
   
that was just typing error...i've improved the solution
PIEBALDconsult 24-Jan-13 13:01pm
   
The compiler takes offense at "typing errors".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900