+ 1
How to write c++ program to generate random number
Write a program which defines three functions 1. genRandNum() This will generate 5 random numbers in range 1-100 and store them in array and print array on console. 2. findMinNum() This will search smallest number in unsorted part of array. 3. swapValue() If left number is smallest number then no need to swap otherwise swap the smallest number with left most unsorted number using swapValue().
8 ответов
+ 2
"std::unsigned(time)" --> srand((unsigned)time(NULL));
rand() % 2; // "This will generate a number from 0 to 2" --> 0 to 1
+ 3
"can you please write all code here..?"
We do, Ahmad. But we get motivated if we see your attempt, first. Have you tried to implement something?
+ 3
"if you want i will show you"
That would be great. Attach your code here for inspection.
+ 2
None of them,
here is one of them you can do:
#include <iostream>
#include <time.h>
#include <cstdlib>
int main(){
std::unsigned(time)
std::cout << rand() % 2;
}
//This will generate a number from 0 to 2
+ 1
plus also this is off-topic,
make sure to read Guidelines
https://www.sololearn.com/discuss/1316935/?ref=app
before posting.
0
can you please write all code here..?
0
yes but failed every time
0
if you want i will show you