0% found this document useful (0 votes)
55 views4 pages

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

The document contains 5 programming problems: 1. Write a program to print increasing sequences of numbers from 1 to nth iteration. 2. Write a program that takes n values from the user and sorts them in ascending order. 3. Write a guessing game that allows the user to guess a secret number and tells them if their guess is too high or too low, printing the number of tries at the end. 4. Write a program to calculate the factorial of a given number. 5. No details are provided for the 5th problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views4 pages

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

The document contains 5 programming problems: 1. Write a program to print increasing sequences of numbers from 1 to nth iteration. 2. Write a program that takes n values from the user and sorts them in ascending order. 3. Write a guessing game that allows the user to guess a secret number and tells them if their guess is too high or too low, printing the number of tries at the end. 4. Write a program to calculate the factorial of a given number. 5. No details are provided for the 5th problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.

You might also like