Method should accept two parameters. one parameter is to display number & second parameter is row

Posted by Rajasekhar0544 under C# on 7/4/2013 | Points: 10 | Views : 663 | Status : [Member] | Replies : 1
Dear All,

I need it in console application, a method should accept two parameters. one parameter is to display number & second parameter is row count.

Example : Print(7,4)

Output :

7
14 15
28 29 30 31
56 57 58 59 60 61 62 63

Please help me.

Thanks.




Responses

Posted by: Nadeemshaik on: 7/9/2013 [Member] Starter | Points: 25

Up
0
Down
public void Print(int Value_Enter, int RowCount)

{
int num, i, j, k, Value, Temp = 0, TempVal = 0;
Value = Value_Enter;
num = RowCount;
for (i = 1; i <= num; i++)
{
for (j = 1; j < num - i + 1; j++)
{
// Console.Write(" ");
}

if (i == 1 || i == 2)
{
for (k = 1; k <= i; k++)
{
if (i == 1)
{
Console.Write(Value);
}
else
{
Console.Write(Value * 2 + (k - 1));
}
Console.Write(" ");
}
Temp = i;
TempVal = Value * 2;
}
else
{
for (k = 1; k <= Temp * 2; k++)
{
Console.Write((TempVal * 2) + (k - 1));
Console.Write(" ");
}
Temp = Temp * 2;
TempVal = (TempVal * 2);
}
Console.WriteLine();

}
Console.ReadLine();
}


Rajasekhar0544, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response