Hello, I am trying to make the program randomly generate one of the words that are inside the vector, which is missing | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Hello, I am trying to make the program randomly generate one of the words that are inside the vector, which is missing

#include <iostream> using namespace std; int main(){ srand(time(0)); string ju[2] = {"a","b"}; ju[2]=rand()%(0,1); cout << ju[2]; }

23rd Apr 2020, 2:14 PM
KeynerZzz
KeynerZzz - avatar
2 Réponses
+ 3
#include <iostream> using namespace std; int main(){ srand(time(0)); string ju[2] = {"a","b"}; cout << ju[rand()%2]; }
23rd Apr 2020, 2:18 PM
HonFu
HonFu - avatar
0
Please clarify, do you want to print either a or b randomly?
23rd Apr 2020, 2:18 PM
Prabhakar Rai
Prabhakar Rai - avatar