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 code verification?

716


What is using keyword?

685


Wht executescaler method is used?

719


Suppose two interfaces have same method, so how will you implement these methods in derive class?

681


What is iqueryable in c#?

664


What is extension method in c# and how to use them?

666


What is cache memory in c#?

652


What are the properties of string?

691


What is meaning of type safety in c#?

641


What is the difference between public, static, and void?

654


What is double c#?

718


What is multidimensional array in c#?

669


What are extension methods and where can we use them?

649


hi all.... i need code snippets for store and retrive tiff fromat images in sqlserver....... kindy provide it.......

1574


is it possible to access a remote web service Without UDDI?

764