1. Write a program using a loop that prints the following output.
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 . . . nth iteration.
using System;
[Link]("\n");
using [Link];
using [Link];
for (int i = 1; i <= value; i++)
using [Link];
using [Link];
for (int j = 1; j <= i; j++)
namespace Problem12
{
classProblem12
[Link](i);
staticvoid Main(string[] args)
[Link](" ");
int value;
[Link]();
[Link]("Enter A Value:");
value = Convert.ToInt32(Console.R
eadLine());
}
Output:
2. Write a program that takes n values from user and then sorts them in ascending order.
using System;
using [Link];
staticvoid Main(string[] args)
{
using [Link];
int num;
using [Link];
int temp;
using [Link];
namespace Problem34
[Link]("Enter The Numbers Yo
u Want To Enter:");
{
num = Convert.ToInt32([Link]
classProblem34
{
adLine());
int[] array = newint[num];
temp = array[j];
for (int i = 0; i < num; i++)
array[j] = array[j + 1];
array[j + 1] = temp;
}
[Link]("Enter " + i + " Value:")
;
}
array[i] = Convert.ToInt32(Cons
[Link]());
[Link]("In Ascending Order:");
for (int i = 0; i < num; i++)
for (int i = 0; i < num ; i++)
{
for (int j = 0; j < num - 1; j++)
[Link](array[i]);
}
[Link]();
}
if (array[j] > array[j + 1])
}
{
}
Output:
3. Write a guessing game where the user has to guess a secret number.
After every guess the program tells the user whether their number was
too large or too small. At the end the number of tries needed should be
printed. I counts only as one try if they input the same number multiple
times consecutively.
4. Factorial of N.
[Link]("Enter a number: ")
Dim num As Integer = [Link]
Dim total As Integer = num
For i As Integer = 1 To num - 1
total = total * (num - i)
Next
[Link]([Link])
[Link]()
5.