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
brief note on multiple stack


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Functions Overloading This a capability in which a C++ program can have several functions performing similar tasks on different data types. When an overloaded function is calle

Aim: To implement a program for dynamic data structure(linked list). Code:                       class node {             int data;             node *next;

Constructors and Destructors: A Class is defined as constructor by declaring a constructor in the form of function inside the class.  In other word a function in the name of

Threaded binary tree: Consider the linked illustration of a binary tree 'T.  Approximately half of the entries is the pointer fields 'LEFT' and 'RIGHT' will have null elements. Th

Explain Processing A Data File? Mainly data file applications needs that a data file be altered as it is being processed. For instance in an application involving the processin

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

smugglers transfer the messages from one to another by using the mobile