473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how would i use while loop to create a range between 100-299 of rndom numbers

so im tryin to create a program that generates 10 random numbers that display on screen that ranges from 100 to 299 im brand new to C++ and could use some help this is what i have so far it just keeps closing on me befor i get to input a number
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9.     {
  10.         srand(static_cast<unsigned int>(time(0))); //seed random number generator
  11.         int randomNumber = rand(); //generate random number
  12.         int number = (randomNumber % 299) + 100; // get a number between 100 and 299
  13.         cout << "Your number is between 100 & 199 " <<              number << endl;
  14.         return 0;
  15.  
  16.         system("pause");
  17.     }
  18.  
  19.     system("pause");
  20. }
Nov 6 '15 #1
1 930
weaknessforcats
9,208 Expert Mod 8TB
The program never gets to your system("pause") because you return right after you display your result.

Probably you see a blink and its over.

Take out that return.
Nov 6 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: August1 | last post by:
A handful of articles have been posted requesting information on how to use these functions in addition to the time() function as the seed to generate unique groups (sets) of numbers - each group...
2
by: Eric Lilja | last post by:
Hello, I'm working on my C++ homework and I have a question about the following function. It's part of my code the handles command line arguments. Here's the code: static void...
0
by: navneetbatra | last post by:
hi I am facing a strange problem in using MSHTML. AS i am using it in .net i am opening page in a win form application and then capture the snippet or text and get the bookmarks and save it in...
3
by: triplejump24 | last post by:
Hey. Im trying to make program that basically displays all the prime numbers. I need to use bool and for but im not quite sure if i have this right. So far i have this bunch of a mess but can...
23
by: Greatness | last post by:
How would i write a while loop that displays no negative numbers???
3
by: aries | last post by:
1 vb application to design a screen saver using timer. 2 vb program to convert a number to wordings(upto 1000)
1
by: wesley1970 | last post by:
<div name="wenben" id="wenben">HighLight me and Click Button</div> <input onClick="makeitbig()" type="button" value="make it big"> <script> function makeitbig(){ if...
2
Steel546
by: Steel546 | last post by:
public static void main(String args) { double modArray= new double; for (int i =1, i < modArray.length(), i++){ modArray= (26*i+7)%31; }...
3
by: Suganthar | last post by:
I have a text box. When I write first text , then java script function will fire to check whether it is a number. For IE , the following code is returning -1 value, But Other browsers it does not...
3
by: khangho | last post by:
Hi. I am a beginner at C++ and for one of my project involves loop inside loops and creating random numbers. Here is what I have so far:#include <iostream> #include <string> #include <cstdlib>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.