how to modulo 10^9+7

C++
In most of the programming competitions, 
we are required to answer the result in 10^9+7 modulo. 
The reason behind this is, 
if problem constraints are large integers, 
only efficient algorithms can solve them in allowed limited time.

use :
const unsigned int M = 1000000007; 
Source

Also in C++: