Reader Level:

Display Number From 1 to 100 Without Loop in Windows Store App

By Satya Prakash on Feb 07, 2013
In this article I explain how to display a number from 1 to 100 without a loop in a Windows Store App.


Today I am describing a very simple but interesting thing. Because we always print number from 1 to 100 using a loop. But someone asked me how to print these numbers without using a loop. Really at that time I had no idea although I proceeded to do it. I finally got the idea to use recursion (in which a method calls itself) and print the number.

Use the following procedure to implement it.

Step 1

First of all you have to create a new Windows Store Application, as in:

  • Open Visual Studio 2012
  • "File" -> "New" -> "Project..."
  • Choose "Template" -> "Visual C#" -> "Window Store app"
  • Choose "Blank App (XAML)" then rename the application


Step 2

Write the following XAML code in "Mainpage.Xaml" (that is available in Solution Explorer):










    <Grid Background="Red">


            <RowDefinition Height="116*"/>

            <RowDefinition Height="45*"/>

            <RowDefinition Height="518*"/>

            <RowDefinition Height="89*"/>



            <ColumnDefinition Width="215*"/>

            <ColumnDefinition Width="479*"/>           

            <ColumnDefinition Width="200*"/>


        <TextBlock Text="Display Number from 1 to 100 without loop" FontSize="20" FontWeight="ExtraBold" FontFamily="Arial" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"></TextBlock>

        <TextBlock x:Name="text1"  FontSize="20" FontWeight="ExtraBold" FontFamily="Arial" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Width="722" TextWrapping="Wrap" Margin="0,0,0,40"></TextBlock>       




Step 3

Now write the following C# code for the button within "Mainpage.Xaml.cs".

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using Windows.Foundation;

using Windows.Foundation.Collections;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Controls.Primitives;

using Windows.UI.Xaml.Data;

using Windows.UI.Xaml.Input;

using Windows.UI.Xaml.Media;

using Windows.UI.Xaml.Navigation;


namespace number_app


    public sealed partial class MainPage : Page


        public MainPage()




        protected override void OnNavigatedTo(NavigationEventArgs e)




        public void number(int num)


            if(num <=100)


            text1.Text += num.ToString() + " ";

            number(num + 1);






Step 4

Run your app and see the output.




Spire.Doc - Free .NET Word API
Use Spire.Doc to create, read, write, print, and convert word documents to OpenXML, RTF, TXT, XPS, EPUB, EMF, HTML, Image and PDF.

Trending up

Infragistics jQuery Controls