Code Challenge: "Hello, World"

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

41 Replies - 18334 Views - Last Post: 06 February 2015 - 07:24 AM

#31 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1624
  • View blog
  • Posts: 5,716
  • Joined: 03-August 09

Re: Code Challenge: "Hello, World"

Posted 15 May 2013 - 09:03 AM

ya, that means I missed something :P
Was This Post Helpful? 0
  • +
  • -

#32 anhtai116  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-June 13

Re: Code Challenge: "Hello, World"

Posted 07 June 2013 - 09:58 AM

Let do something with OOP
Spoiler

This post has been edited by Skydiver: 16 June 2014 - 09:15 PM
Reason for edit:: Put code in spoiler tags to keep challenge fresh for everybody.

Was This Post Helpful? 0
  • +
  • -

#33 hemantwithu  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 31
  • Joined: 18-October 11

Re: Code Challenge: "Hello, World"

Posted 29 May 2014 - 11:44 PM

It's a nice challenge to compete . Here is my code
Spoiler

This post has been edited by Skydiver: 16 June 2014 - 09:14 PM
Reason for edit:: Put code in spoiler tags to keep challenge fresh for everybody.

Was This Post Helpful? 0
  • +
  • -

#34 Urganot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-June 14

Re: Code Challenge: "Hello, World"

Posted 16 June 2014 - 06:00 AM

Cool Challenge
Spoiler

Was This Post Helpful? 0
  • +
  • -

#35 Xaos  Icon User is offline

  • D.I.C Regular

Reputation: 78
  • View blog
  • Posts: 397
  • Joined: 20-November 13

Re: Code Challenge: "Hello, World"

Posted 16 June 2014 - 06:15 AM

Heh, my first coding challenge on the site. 'Twas interesting!
Spoiler

This post has been edited by Skydiver: 16 June 2014 - 09:12 PM
Reason for edit:: Put code in spoiler tags to keep challenge fresh for everybody.

Was This Post Helpful? 0
  • +
  • -

#36 JasenS  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 26-August 14

Re: Code Challenge: "Hello, World"

Posted 28 August 2014 - 04:53 AM

Nice little thought provoking exercise. Here's what I just jotted down this morning.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace helloworldloop
{
    class Program
    {
       static int count = 0;
        
    
        static void Main(string[] args)
        {
            hello();
        }

       static void hello()
        {
            if (count < 1001)
            {
                Console.WriteLine("Hello World!!!!" + count.ToString());
                count++;
                hello();
            }
            else
            {
                Console.WriteLine("Welp, we're at 1000");
            }
        }
        
    

    }
}






It's almost Friday, so here we are. :D
Was This Post Helpful? 0
  • +
  • -

#37 cruse07  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-October 14

Re: Code Challenge: "Hello, World"

Posted 14 October 2014 - 07:46 AM

class Program
{
static int x = 0;
Program()
{
Console.WriteLine(x+": HELLO WORLD",++x);
if (x == 1000)
{
// System.Environment.Exit(0);
Console.ReadKey();
return;
}
new Program();

}

static void Main(string[] args)
{
new Program();
Console.ReadKey();

}
}
Was This Post Helpful? 0
  • +
  • -

#38 Chepetico  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-October 14

Re: Code Challenge: "Hello, World"

Posted 23 October 2014 - 08:21 PM

Hey, great challenge! Here is my answer:

using System;

namespace HelloWorldRecursion
{
    class Program
    {
        static void Main(string[] args)
        {
            int numberOfIterations = randomNumberGenerator.Next(1001);

            string numberOfTimes = numberOfIterations == 1 ? "time" : "times";

            Console.WriteLine("Hello World Repeated Using Recursion!\n");

            Console.WriteLine("Hello World will be repeated " + 
                numberOfIterations.ToString() + " " + numberOfTimes + ".\n");

            Console.WriteLine("Press 'Enter' to continue.\n");

            Console.ReadLine();

            int count = 0;

            RecursiveDisplayOfHelloWorld(ref count, ref numberOfIterations);

            Console.WriteLine("\nPress 'Enter' to continue.\n");

            Console.ReadLine();
        }

        public static Random randomNumberGenerator = new Random();

        public static void RecursiveDisplayOfHelloWorld(ref int count, ref int numberOfIterations)
        {
            if (count < numberOfIterations)
            {
                count++;

                Console.WriteLine(count.ToString() + " Hello World!");

                RecursiveDisplayOfHelloWorld(ref count, ref numberOfIterations);
            }
            else
            {
                return;
            }
        }
    }
}


Was This Post Helpful? 0
  • +
  • -

#39 Chepetico  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-October 14

Re: Code Challenge: "Hello, World"

Posted 23 October 2014 - 10:45 PM

Actually,

int numberOfIterations = randomNumberGenerator.Next(1001);



Should be

int numberOfIterations = randomNumberGenerator.Next(1, 1000);



and the final

Console.WriteLine("\nPress 'Enter' to continue.\n");



Should be

Console.WriteLine("\nPress 'Enter' to exit.\n");


Was This Post Helpful? 0
  • +
  • -

#40 microsophtdeveloper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-January 15

Re: Code Challenge: "Hello, World"

Posted 02 January 2015 - 09:23 AM

namespace Hello_World
{
class Program
{
static void Main(string[] args)
{
int n = 1000;
string msg = "Hello World\n";
StringBuilder st = new StringBuilder();
Console.WriteLine(st.Insert(0,msg,n));
Console.ReadLine();
}
}
}
Was This Post Helpful? 0
  • +
  • -

#41 Orace  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-February 15

Re: Code Challenge: "Hello, World"

Posted 06 February 2015 - 06:48 AM

Recursive call can lead to stack overflow.
Using divide and conquer, the risk is low.

    static class Program
    {
        static void Main()
        {
            PrintA("Hello World !", 1000);
            Console.ReadKey();
        }

        static void PrintA(string text, uint i)
        {
            switch (i%2 + ((i==1) ? 41 : 0))
            {
                case 0:
                    PrintA(text, i/2);
                    PrintA(text, i/2);
                    break;
                case 1:
                    PrintA(text, i / 2);
                    PrintA(text, 1);
                    PrintA(text, i / 2);
                    break;
                case 42:
                    Console.WriteLine(text);
                    break;
            }
        }

    }


Was This Post Helpful? 0
  • +
  • -

#42 Orace  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-February 15

Re: Code Challenge: "Hello, World"

Posted 06 February 2015 - 07:24 AM

Fix the infinite loop in case of the number was 0.
Spoiler

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3