making random numbers in c++
C++
/* rand example: guess the number */
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
int main ()
{
int iSecret, iGuess;
/* initialize random seed: */
srand (time(NULL));
/* generate secret number between 1 and 10: */
iSecret = rand() % 10 + 1;
do {
printf ("Guess the number (1 to 10): ");
scanf ("%d",&iGuess);
if (iSecret<iGuess) puts ("The secret number is lower");
else if (iSecret>iGuess) puts ("The secret number is higher");
} while (iSecret!=iGuess);
puts ("Congratulations!");
return 0;
}
Also in C++:
- Title
- what does count function do in hashmap
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- queue c++
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- c++ iterate through constant list
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- pass vector by reference c++
- Category
- C++
- Title
- c++ char if
- Category
- C++
- Title
- c++ function return array
- Category
- C++
- Title
- getline not working c++
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- Temporary file using MSFT API in cpp
- Category
- C++
- Title
- queue stl c++
- Category
- C++
- Title
- max three values c++
- Category
- C++
- Title
- how print fload wiht 3 decimal in c++
- Category
- C++
- Title
- get data from terminal c++
- Category
- C++
- Title
- c++ initialize a vector
- Category
- C++
- Title
- c++ remove item from list
- Category
- C++
- Title
- log base 10 c+_+
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- c++ show time elapsed
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- matrix class in c++
- Category
- C++
- Title
- findung the mode in c++
- Category
- C++
- Title
- container class in c++
- Category
- C++
- Title
- convert decimal to binary in c++
- Category
- C++
- Title
- c++ class member initialization
- Category
- C++
- Title
- c++ clamp
- Category
- C++
- Title
- convert string to stream c++
- Category
- C++
- Title
- How to find the suarray with maximum sum using divide and conquer
- Category
- C++
- Title
- set lower bound c++
- Category
- C++
- Title
- How to traverse in a tree iterative C++
- Category
- C++
- Title
- find height of a tree
- Category
- C++
- Title
- How to read a file in in C++
- Category
- C++
- Title
- ue4 c++ enum
- Category
- C++
- Title
- two sum problem in c++
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- in c, is class uppercase or lowercase
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- initialising 2d vector
- Category
- C++
- Title
- c++ get ascii value of char
- Category
- C++
- Title
- memset c++
- Category
- C++
- Title
- removing repeated characters in a string c++
- Category
- C++
- Title
- c++ replace substrings
- Category
- C++
- Title
- loop through array c++
- Category
- C++
- Title
- Insert into vector C++
- Category
- C++
- Title
- inheritance protected in c++
- Category
- C++
- Title
- how to avoid tle in c++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- #include
- Category
- C++
- Title
- double ended queue in c++ stl
- Category
- C++
- Title
- c++ get length of array
- Category
- C++
- Title
- cout value c++
- Category
- C++
- Title
- single line if c++
- Category
- C++
- Title
- how to inject a dll into a game c++
- Category
- C++
- Title
- create new file c++
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- & in xml
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- level order traversal
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- how to convert a string to a double c++
- Category
- C++
- Title
- sleep system function linux c++
- Category
- C++
- Title
- initialize array c++
- Category
- C++
- Title
- initialize vector of pointers c++
- Category
- C++
- Title
- string input
- Category
- C++
- Title
- initialize vector of vector c++
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- binary search stl in c++
- Category
- C++
- Title
- elseif c++
- Category
- C++
- Title
- c++ delete dynamically allocated array
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- int to float c++
- Category
- C++
- Title
- how to have a queue as a parameter in c++
- Category
- C++
- Title
- call by reference c++ example
- Category
- C++
- Title
- add a timer c++
- Category
- C++
- Title
- c++ program to find gcd of 3 numbers
- Category
- C++
- Title
- double to string c++
- Category
- C++
- Title
- function declerations in C++
- Category
- C++
- Title
- substr in c++
- Category
- C++
- Title
- how to get input from the console in c++
- Category
- C++
- Title
- how can make string value in cpp
- Category
- C++
- Title
- command line options in c++
- Category
- C++
- Title
- matrix transpose tiling
- Category
- C++
- Title
- how initilaize deffult value to c++ class
- Category
- C++
- Title
- find in string c++
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- msdn parse command line
- Category
- C++
- Title
- best fit algorithm
- Category
- C++
- Title
- filling 2d array with 0 c++
- Category
- C++
- Title
- Find the minimum difference between pairs in a simple path of tree C++
- Category
- C++
- Title
- struct c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- insert at position in vector c++
- Category
- C++
- Title
- c++ sort vector of objects by property
- Category
- C++
- Title
- console colors in C++
- Category
- C++
- Title
- mingw32/bin/ld.exe: C:\Users\mfrom\AppData\Local\Temp\ccSKcRks.o:PizzaPi.cpp:(.text$_ZN5PizzaC2Ev[__ZN5PizzaC2Ev]+0xa): undefined reference to `vtable for Pizza' collect2.exe: error: ld returned 1 exit status
- Category
- C++
- Title
- max element in array c++ stl
- Category
- C++