<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Programming on alinuxuser</title>
    <link>https://alinuxuser.com/tags/programming/</link>
    <description>Recent content in Programming on alinuxuser</description>
    <image>
      <title>alinuxuser</title>
      <url>https://alinuxuser.com/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://alinuxuser.com/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 05 Sep 2017 05:38:00 -0500</lastBuildDate>
    <atom:link href="https://alinuxuser.com/tags/programming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Towers Of Hanoi in Java</title>
      <link>https://alinuxuser.com/posts/2017/09/2017-09-05-towersofhanoi/</link>
      <pubDate>Tue, 05 Sep 2017 05:38:00 -0500</pubDate>
      <guid>https://alinuxuser.com/posts/2017/09/2017-09-05-towersofhanoi/</guid>
      <description>&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;package recursion;

import java.util.Scanner;

public class TowersOfHanoi
{

    public static void main(String[] args)
    {
//      Scanner input = new Scanner(System.in);
//
//      System.out.println(&amp;#34;Enter the number of discs: &amp;#34;);
//      int numberOfDiscs = input.nextInt();
//
//      towersOfHanoi(numberOfDiscs, &amp;#34;A&amp;#34;, &amp;#34;B&amp;#34;, &amp;#34;C&amp;#34;);
        towersOfHanoi(3, &amp;#34;A&amp;#34;, &amp;#34;B&amp;#34;, &amp;#34;C&amp;#34;);

    }

    public static void towersOfHanoi(int discs, String source, String to, String destination)
    {
        if (discs == 1)
        {
            System.out.println(source + &amp;#34; --&amp;gt; &amp;#34; + destination);
        }
        else
        {
            towersOfHanoi(discs - 1, source, destination, to);
            System.out.println(source + &amp;#34; --&amp;gt; &amp;#34; + destination);
            towersOfHanoi(discs - 1, to, source, destination);
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Runtime Array in C#</title>
      <link>https://alinuxuser.com/posts/2012/09/2012-09-11-runtimearray/</link>
      <pubDate>Tue, 11 Sep 2012 13:11:00 -0500</pubDate>
      <guid>https://alinuxuser.com/posts/2012/09/2012-09-11-runtimearray/</guid>
      <description>&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;/*
 * This program, accepts the size of the array from the user.
 * Check to see if the size is a number, if its not, it will
 * display a message and terminate.
 * If it is, the user is asked to enter the elements into the
 * array.
 * Each element is parsed into int. if it is not successful, a
 * message is displayed.
 * there are two functions which do the same conversion, but
 * display different exit messages depending on the element that
 * is incorrect. The last element will have a different exit message
 * if the value is incorrect.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RuntimeArray
{
    class RuntimeArray
    {
        static void Main(string[] args)
        {
            Console.WriteLine(&amp;#34;Enter the size of the array: &amp;#34;);
            string s = Console.ReadLine();
            int size;
            //take the number in string s, convert it into int and store it in size
            bool NumerOrNot = Int32.TryParse(s, out size);

            //if s is not a number, print out a message and exit
            if (!NumerOrNot)
            {
                Console.WriteLine(&amp;#34;This is not a number. &amp;#34;);
                Console.WriteLine(&amp;#34;Press enter to terminate.&amp;#34;);
                Console.Read();
            }

            string[] s1 = new string[size];
            Console.WriteLine(&amp;#34;Enter {0} numbers&amp;#34;, size);
            for (int i = 0; i &amp;lt; size; i++)
            {
                //reading elements from the console
                s1[i] = Console.ReadLine();
                //the exit message is different for the last element of the array
                if (i == size - 1)
                {
                    //a different function is called with a different exit message
                    //this function will try to parse the element into int.
                    TryToParse2(s1[i]);

                }
                else
                {
                    //this function will try to parse the element into int.
                    TryToParse(s1[i]);
                }

            }
            Console.WriteLine(&amp;#34;All the elements entered so far: &amp;#34;);
            for (int j = 0; j &amp;lt; size; j++)
            {
                Console.WriteLine(&amp;#34;Element {0}: {1}&amp;#34;, j, s1[j]);
            }
            Console.WriteLine(&amp;#34;Press enter to terminate.&amp;#34;);
            Console.Read();
        }
        public static bool TryToParse(string s2)
        {
            int number;

            s2.Trim();
            bool result = Int32.TryParse(s2, out number);

            if (result)
            {
                Console.WriteLine(&amp;#34;The string {0}, has been parsed into the number: {1}&amp;#34;, s2, number);
            }
            else
            {
                Console.WriteLine(&amp;#34;This is not a number. Enter a number: &amp;#34;);

            }
            return true;
        }
        public static bool TryToParse2 (string s3)
        {
            int number;

            s3.Trim();
            bool result = Int32.TryParse(s3, out number);

            if (result)
            {
                Console.WriteLine(&amp;#34;The string {0}, has been parsed into the number: {1}&amp;#34;, s3, number);
            }
            else
            {
                Console.WriteLine(&amp;#34;This is not a number.&amp;#34;);

            }
            return true;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
  </channel>
</rss>
