Program to print 1-100 numbers in C# without using loops
List<int> list = Enumerable.Range(number, 100).ToList();string s = string.Join(", ",list.Select(x =>x.ToString()));Console.WriteLine(s);
List<int> list = Enumerable.Range(number, 100).ToList();
string s = string.Join(", ",list.Select(x =>x.ToString()));
Console.WriteLine(s);
public class Hundred{ public static int printNumber(int number) { if (number == 101) return 0; Console.Write(string.Format("{0}{1}", number, number != 100 ? ", " : ".")); return printNumber(number + 1); }}
public class Hundred
{
public static int printNumber(int number) {
if (number == 101)
return 0;
Console.Write(string.Format("{0}{1}", number, number != 100 ? ", " : "."));
return printNumber(number + 1);
}
use recursive function exit when number reached to 100
using System; class GFG{ static public void Main () { int i = 0; begin: i = i + 1; Console.Write(" " + i + " "); if (i < 100) { goto begin; } } }
using System;
class GFG{
static public void Main ()
int i = 0;
begin:
i = i + 1;
Console.Write(" " + i + " ");
if (i < 100)
goto begin;