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

Answers were Sorted based on User's Feedback



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

Answer / santosh sasane

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

//( Solved With the Console Application in .net )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{

class Program
{

static void Main(string[] args)
{ int q = 10;
int p = 10;
for (int i = 0; i < 10; i++)
{
for (int j = i; j <= i; j++)
{
StringBuilder a = new StringBuilder();
if (q == 10)
{
a.Append(j - i);
}
for (int k = q; k <= 9; k++)
{
a.Append(k);
if (k == 9) { a.Append(0); }
}
for (int g = 9; g >= q; g--)
{
a.Append(g);
}
q--;
p--;
Console.WriteLine(a);
}
}
Console.ReadLine(); // Used for hold the Disply
}
}
}

Is This Answer Correct ?    3 Yes 0 No

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

Answer / tanvi

Assignment 1:
namespace PrintExcercise
{
class Program
{
static void Main(string[] args)
{
string xx;

for (int i = 0; i < 8; i++)
{
xx = "XX XX";
if (i == 3 || i == 4)
{
xx = xx.Remove(xx.Length - 1, 1);
xx = xx.Remove(0, 1);
}

Console.WriteLine(xx);
}

}
}
}

Is This Answer Correct ?    0 Yes 0 No

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

Answer / 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

More C Sharp Interview Questions

What is token in c#?

0 Answers  


Is it possible to inline assembly or il in c# code?

0 Answers  


What is Fragmentation and its Types?

0 Answers   MCN Solutions,


What are the properties of a string class?

0 Answers  


What is boxing? Explain its functionality?

0 Answers   Siebel,






What are the ways to deploy an assembly?

3 Answers  


How can I make sure my c# classes will interoperate with other .net languages?

0 Answers  


What are different types of classes in c#?

0 Answers  


what is the difference between a struct and a class in c#?

0 Answers   4Cplus,


What is difference between static and constant variable?

0 Answers  


What are the differences between value types and reference types?

0 Answers  


What is default value of bool in c#?

0 Answers  


Categories