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

List the difference between interface and abstract class?

468


In .NET how can you solve the DLL Hell problem?

669


What are cshtml files?

486


What is part of a method signature in c#?

465


What Is The Smallest Unit Of Execution In .net?

522






When should we use sealed class in c#?

488


Is arraylist type safe in c#?

498


Why we use get and set method in c#?

495


How to transpose multi-dimensional array?

556


While debugging a C# application can you change the value of a variable?

534


What are the different states of a thread?

530


What are console applications used for?

478


What is session variable in c#?

557


Give examples for reference types?

536


Why is hashset faster?

489