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
Are private members inherited in c#?
What is the use of base keyword? Tell me a practical example for base keyword’s usage?
What benefit do you get from using a primary interop assembly (pia)?
What does writeline mean?
What is the data provider name to connect to access database?
How to sign an assembly with strong name?
What is a class c#?
Do we get an error while executing the “finally” block in c#?
What is the predicate of a sentence?
What is Implicit conversion in C#?
Can a loop recorder detect a heart attack?
What is the default value of singleordefault?
How many parameters can a method have c#?
how to sort an array in c#
What is collection of classes in c#?