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
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
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;
Console.WriteLine("\n");
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
for (int j = 1; j <= i; j++)
namespace Problem12
{
classProblem12
Console.Write(i);
Console.Write(" ");
int value;
Console.ReadKey();
Console.WriteLine("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 System.Collections.Generic;
using System.Linq;
int num;
using System.Text;
int temp;
using System.Threading.Tasks;
namespace Problem34
{
num = Convert.ToInt32(Console.Re
classProblem34
{
adLine());
int[] array = newint[num];
temp = array[j];
for (int i = 0; i < num; i++)
array[j + 1] = temp;
}
;
}
array[i] = Convert.ToInt32(Cons
ole.ReadLine());
Console.WriteLine(array[i]);
}
Console.ReadKey();
}
{
}
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.
Console.Write("Enter a number: ")
Dim num As Integer = Console.ReadLine
Dim total As Integer = num
For i As Integer = 1 To num - 1
total = total * (num - i)
Next
Console.WriteLine(total.ToString)
Console.ReadLine()
5.