Numbers:

Numbers are usually the variables that are assigned certain values and have some data types. For example int, unsigned int, long, double, etc.

These have already been discussed in previous chapter. The example for defining numbers is as follows:

int a;

short b;

long c;

Data type of Number Number Number initialization Number printing
int A A = 30 cout<<A;
short B B = 10 cout<<B;
Unsigned int C C = 20 cout<<c;

Numbers are also operands i.e. on which the operations are being done. Operations can be any operation for example arithmetic operations including addition, multiplication etc.

C++ programming language also provides various mathematics operation or scientific operations. For example sine, cosine functions, for this we have to include a header file. The header file for these functions is <cmath> .

In C++ we can generate random numbers by using a built in function that is rand(). This function generates or returns random integral number.

EXAMPLE

Variable1= rand () % 100;

Where modulus 100 is used here to limit the range of the returned value. And the new generated number will be assigned to Variable1.