Assignment # 1 Print the pattern given below using single
printf statement

XX XX
XX XX
XX XX
X X
X X
XX XX
XX XX
XX XX


Assignment # 2 Print the pattern given below using single
printf statement
(please do NOT use the string function below)
0
909
89098
7890987
678909876
56789098765
4567890987654
345678909876543
23456789098765432
1234567890987654321

Answer Posted / vinay s m

Assignment 2 :
static void Main(string[] args)
{
int n = 10;
for (int i = 0; i < n; i++)
{
StringBuilder a = new StringBuilder();
for (int j = n - i; j < n; j++)
{
a.Append(j);
}
a.Append(0);
for (int k = n-1; k >=n-i; k--)
{
a.Append(k);
}
Console.WriteLine(a);
}
Console.Read();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between static class and abstract class in c#?

456


What does private void mean in c#?

535


Explain metadata in c#.

488


Is c sharp and c# are same?

503


What is parameters in c#?

493






What does string intern do?

483


What is JIT (just in time)? how it works?

547


How does aspect oriented programming work?

503


What are Uses of CLR

528


What is the purpose of dependency injection?

470


The int maps to which C# keyword in .NET type?

658


What is data annotation in c#?

498


Do we get an error while executing the “finally” block in c#?

503


What is sql transaction in c#?

473


Why are strings in c# immutable?

491