Computer Science, asked by ziaaqsa9, 8 months ago

Question 3:
Write a c++ program that uses six calls to the function rand to generate six random integer numbers,
numl, num2, num3, num4, num5, and num6, and then print them out. numl should be in the
range 1 to 2 (inclusive), nunı2 should be in the range 1 to 100 (inclusive), num3 should be in the
range 0 to 9, num4 should be in the range 1000 to 1112 (inclusive), num5 should be in the range
-1 to 1, and num6 should be in the range -3 to 11.​

Answers

Answered by ahad74635
2

Answer:

#include <iostream>

#include <cstdlib> // for std::rand() and std::srand()

 

int main()

{

    std::srand(5323); // set initial seed value to 5323

 

    // Print 100 random numbers

    for (int count{ 1 }; count <= 100; ++count)

    {

        std::cout << std::rand() << '\t';

 

        // If we've printed 5 numbers, start a new row

        if (count % 5 == 0)

            std::cout << '\n';

}

 

    return 0;

}

Similar questions