TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
326k
Next Method (Int32, Int32)
Oct 8 2013 8:57 AM
This program is given in the following website.
http://msdn.microsoft.com/en-us/library/2dx6wyd4.aspx
When calculating random integers, in Next() method always 1 is added to the upper limit. Please tell me the reason. Problem is highlighted.
using System;
public class Example
{
public static void Main()
{
Random rnd = new Random();
Console.WriteLine("\n20 random integers from -100 to
100
:");
for (int ctr = 1; ctr <= 20; ctr++)
{
Console.Write("{0,6}", rnd.Next(-100,
101
));
if (ctr % 5 == 0) Console.WriteLine();
}
Console.WriteLine("\n20 random integers from 1000 to
10000
:");
for (int ctr = 1; ctr <= 20; ctr++)
{
Console.Write("{0,8}", rnd.Next(1000,
10001
));
if (ctr % 5 == 0) Console.WriteLine();
}
Console.WriteLine("\n20 random integers from 1 to
10
:");
for (int ctr = 1; ctr <= 20; ctr++)
{
Console.Write("{0,6}", rnd.Next(1,
11
));
if (ctr % 5 == 0) Console.WriteLine();
}
Console.Read();
}
}
Reply
Answers (
2
)
ON ERP
Windows form applicaion with expiration date