answersLogoWhite

0


Best Answer

11

User Avatar

Julie Bernier

Lvl 10
3y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

You would use the rand() function followed by a modulus.

For example, for a number between 0 and 9 (10 options)

num1 = rand()%10;

For something like from 50-99 (50 options, starting at 50)

num1 = (rand() % 50) +50

In summary: rand() % numberOfOptions + minNumber

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

For x = 1 to 10

Print x

Loop '(sometimes Next x is used)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you print 10 ramdom numbers by using for loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you print square using for loops?

how to print "square" using for loop


What is odd loop?

Move the print out requesting the user to enter an integer outside of the for loop and it will only print once instead of each time around the loop. You'll need a way to save the even and odd numbers that you detect in the loop. One way is to have separate arrays to hold the even and the odd numbers as you go around the loop. Then at the end of the loop you can have more loops to print the contents of one array and then the contents of the other array. Another way is to concatenate the number onto separate Strings (even and odd) to be displayed after the data gathering loop.


How do you print non-prime numbers in java?

Loop through some numbers - for example, 2 through 100 - and check each one whether it is a prime number (write a second loop to test whether it is divisible by any number between 2 and the number minus 1). If, in this second loop, you find a factor that is greater than 1 and less than the number, it is not a prime, and you can print it out.


Write an algorithm or draw a flowchart to display numbers from 100 down to 10?

n=100 loop until n = 9 print n n = n -1 end loop


Display odd number using for loop?

It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i < 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }

Related questions

How do you print square using for loops?

how to print "square" using for loop


How do you print 1 to 100 without using loop in php?

The best way to print the numbers 1 to 100 in PHP without using a loop is with the following code: echo implode("<br>", range(1,100)); You can replace the <br> with anything that you want to separate the numbers, such as dashes. I used a line-break in the example.


How to draw Flowchart to print prime numbers from 1 to 100 using while loop in c language?

c the book mastering c


How do you print the numbers 1 through 50 using a do-loop while statement in Visual Basic.NET?

x as int = 0 while x < 50 x = x + 1 print x endwhile


To print unique no using for loop?

int main (void) { puts ("unique"); }


What is odd loop?

Move the print out requesting the user to enter an integer outside of the for loop and it will only print once instead of each time around the loop. You'll need a way to save the even and odd numbers that you detect in the loop. One way is to have separate arrays to hold the even and the odd numbers as you go around the loop. Then at the end of the loop you can have more loops to print the contents of one array and then the contents of the other array. Another way is to concatenate the number onto separate Strings (even and odd) to be displayed after the data gathering loop.


How do you print first 10 even number using for loop in q basic?

For N = 1 to 10 Print 2 * N Next N


How do you print non-prime numbers in java?

Loop through some numbers - for example, 2 through 100 - and check each one whether it is a prime number (write a second loop to test whether it is divisible by any number between 2 and the number minus 1). If, in this second loop, you find a factor that is greater than 1 and less than the number, it is not a prime, and you can print it out.


Write an algorithm or draw a flowchart to display numbers from 100 down to 10?

n=100 loop until n = 9 print n n = n -1 end loop


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


How do you alternate the input numbers using for loop in c plus plus?

Input a variable.


How do you write a c program to print n no's required using while loop?

int i=0; while (i++<n) { /*...*/ }