how can i get this 123456789
1234 6789
123 789
12 89
1 9
Answer / tanvir anwar
int n = 9; // you can use any odd number for similar pattern
int mid = (n+1)/2;
for (int i = 0; i < mid; i++)
{
for (int j = 1; j <= n; j++)
{
if (j <= mid-i || j >= mid+i)
Console.Write({0}, j);
else
Console.Write(" ");
}
Console.WriteLine();
}
| Is This Answer Correct ? | 10 Yes | 2 No |
What is method and function in c#?
Do loops in c#?
What is decimal in c#?
Explain the features of an abstract class in net.
What is xml serialization in c#?
What's c# ?
Explain manifest & metadata?
How many constructors can a class have in c#?
What is tpl in c#?
Can a loop recorder detect a heart attack?
What are the characteristics of c#?
Is stringbuilder better than string?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)