Assign random integers to the variable, C/C++ Programming

(Random Numbers) Write statements that assign random integers to the variable n in the following ranges:

a) 1 ≤ n ≤2

b) 1 ≤ n ≤100

c) 0 ≤ n ≤9

d) 1000 ≤ n ≤1112

e) -1≤ n ≤1

f) -3≤ n ≤11

(ii) (Random Numbers) write a single statement that prints a number at random from  each of the following sets:

a) 2, 4, 6, 8, 10

b) 3, 5, 7, 9, 11

c) 6, 10, 14, 18, 22

Hint: rand( ) in gives a random integer between 0 and RAND_MAX, use %  (modulus) operator to limit the range of random numbers generated.

Posted Date: 2/19/2013 1:45:57 AM | Location : United States







Related Discussions:- Assign random integers to the variable, Assignment Help, Ask Question on Assign random integers to the variable, Get Answer, Expert's Help, Assign random integers to the variable Discussions

Write discussion on Assign random integers to the variable
Your posts are moderated
Related Questions
expression and its types with example programs

Purpose For this assignment you will need to create either a function list or a record series for a CRCRS. Instructions Note: Complete only one of the two assignment op

THEORY OF COMPUTER PROGRAMMING

#include stdio.h #include math.h float discharge(float,float); void main()   {   char prompt;      float time,out,cr;   cr = 100e-6;   for (time = 0;time   {   /* call th

Literals (Constants) Constants are data storage locations whose address is not accessible for the user. Their value is not altered during the course of the program. Literal

Reference Types The symbol "&" is interpreted as an address operator as well as AND operator. This operator is also used to declare a "reference variable". A reference is refer

Write a function that takes an array as the argument and returns the second largest element. Bonus (+5): Write a function that takes an array and a number n as arguments and return


need to create c++ classes to store all pascal types in compiler design.

For Loop with inner loop