Generate a random even number in C++
Posted by Samath
Last Updated: January 05, 2017

This is a very simple program that generates a even random number. 

#include <stdio.h>      
#include <stdlib.h>    
#include <time.h>      

int main ()
{
  for(int i = 0;i<100;i++){
    int ret = (rand()%10)/2*2;
    printf("%d\n",ret);  
  }
  
  return 0;
}