Cpp - What values do the following arithmetic expressions have?

Requirements

What values do the following arithmetic expressions have?

a.  3/10              
b.  11%4              
c.  15/2.0 
d.  3 + 4 % 5         
e.  3 * 7 % 4         
f.  7 % 4 * 3 


Click to view the answer

a.   0       
b.  3        
c.  7.5 
d.   7       
e.  1        
f.  9

Demo

#include <iostream> 
using namespace std; 
int main() /*  ww w. jav  a  2s . c  o m*/
{ 
    cout << 3/10   << endl; 
    cout << 11%4 << endl; 
    cout << 15/2.0  << endl; 
    cout << 3 + 4 % 5 << endl; 
    cout << 3 * 7 % 4 << endl; 
    cout << 7 % 4 * 3 << endl; 
    
    return 0; 
}

Result

Related Exercise