random number of 0 or 1 c++

#include <time.h> // So we can use time() function
#include <iostream> // To output results to console

int main() // Main function required in all C++ programs and first function to be called
{
	srand( time(NULL) ); //Randomize seed initialization
	int randNum = rand() % 2; // Generate a random number between 0 and 1

	std::cout << randNum; // Output the results to console
	return 0; //Generate an "EXIT SUCCESS" return code
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
c++ random number -1 or 1 c++ random number from -1 to 1 generate random number in [0, 1] in c++ random number between 0 and 100 c++ c++ get random int between 0 and 10 c++ random numbers between 0 and 1 rand between 0 and 1 c++ how to get a random number between 0 to numbers in C++ generate random between 0 and 250 in c++ generate random number between 0 and 10 in c++ cpp random number between 0 and 12 generate random 0 and 1 c++ c++ function returns random number between 1 and 6 generate random numbers from 0 to 9 in C++ how to generate a random number between 0 and 1 in c++ c++ random between 0 and 10 c++ random number 0 to 1 random numbers between 0 and 3 c++ get a random number between 0 and 1 c++ c++ random number between 0 and 100 better random between 0 and 6 c++ c++ random 0 to 1 c++ random number between 0 and 100000 c++ getting a random number from 0 to 1 how to randomise numbers in c++ from 0-1000 c++ random between 0 and 4 generate a random number between 0 and 1 c++ c++ random number between 0 and 10 c++ random number between 0 1 random 0-1 in c++ construct a random variable between 0 and 1 c++ random number c++ between 0 and 1 generate random double numbers in c++ between 0 - 1 c++ generate random number between 0 and 1 using srand random numbers 0.01 c++ how to generate random numbers between 0 and 1 in c++ random number from 0 to 1 c++ c++ double random 0 1 c++ random nubmer between 0 and 5000 random number between 0 to 13 c++ C++ random double 0 - 1 rand() in c++ between 0 and 1 c++ random number from 1 to 9 c++ random from 0.9 to 1.1 in c c++ random from 0.9 to 1.1 c++ random from 0 to 1 cpp random number between 0 and 1 random 0 1 c++ c++ random number from 0 to 10 c++ rand between 0 and 1 how to print out a random number between 0 and 100 c++ c++ random 0 to 100 c++ random number -1 1 0 to 1 random function in c++ generating random number from 0 to 1 c++ RANDOM NUMBER FROM 0 TO 1 THAT INCLUDES 1 C++ c++ random between 0 and 1 how to make a random number generator in c++ from 0 to 1 random numbers between 0 and 1 C++ generate random 0 and 1 in c++ c++ pick 4 random numbers between 0 and 99 c++ generate random number between 0 and 100 how to get a random number between 0 and 1 in c++ how to use random values in 0 to 10 in cpp c++ random value between 0 and 1 how to randomize between 0 and 1 in c++ c++ generate random number between 0 and 1 random number between 0 and 1 cpp how to get a random npumber between 0 and 100 c++ random 0 or 1 cpp interger c++ random number 0 or 1 random int c++ 0 1 random number between 0 and 1 c++ random number generator c++ between 0 to1 c++ rand number between 0 and one c++ random number between 0 and 1 c++ random integer between 0 and 1 random number of 0 or 1 c++
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source