Interviews3 answers
Write a program to print 1 to 100 without using any types of loop and only have an entry point.
3 Answers
static void Main(string[] args)
{
int i = 1;
repeat:
if (i < 101)
{
Console.WriteLine(i);
i++;
goto repeat;
}
Console.Read();
}
Akintunde ChristainPosted Mar 13, 2018, 8:14 AM EDT
you have used a function.i don't want any function rather than Main() function.
Dinesh RajputPosted Mar 8, 2018, 6:38 PM EST
public static void PrintNext(i) {
if (i <= 100) {
Console.Write(i + " ");
PrintNext(i + 1);
}
}
public static void Main() {
PrintNext(1);
}
jamil shahPosted Nov 24, 2017, 3:29 AM EST
