I need to create console application in C#. A lector does not allow to use array. In this program User has to enter integer number K and collection of integer numbers, which do not = 0 (r!=0). After user have entered 0, the collection ends and the program must show on the screen FIRST number of collection, which was > k. If there were no r > k, it must write "0".
I tried to write code, but have problems with data display.
using System;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
double k, r, l;
Console.WriteLine("Enter k");
k = double.Parse(Console.ReadLine());
r = System.Double.PositiveInfinity;
Console.WriteLine("Enter r");
do
{
r = double.Parse(Console.ReadLine());
if (r > k)
{
l = r;
}
else if (r == 0)
{
l = 0;
break;
}
[U][B]Console.WriteLine(l);[/B][/U]
} while (r != 0);
}
}
}
How can i restructure the program?
Please help!
Sorry for bad English. I hope it is understandable.


Sign In
Create Account

Back to top









