Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Random Numbers Lab

$
0
0
We have a new lab in programming class where we are supposed to use a while loop to generate random numbers until they reach a final sum of 100. I'm not asking for the answers, I was just wondering if anyone could point me in the right direction. Here's the code I have so far. Bare with me here.

namespace Lab16RandomNums
{
    class Program
    {
        static void Main(string[] args)
        {
            // Variables for lab
            Random rand = new Random();
            int sum = 0;
            int num = 0;

            // Code for lab
            while (sum < 100)
            {
                num = rand.Next(10);
                Console.WriteLine("number = " + num);
                
            }
        }
    }
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>