Q:

Will Specific Operators give me different results?

I'm working in my Sam's teach yourself work book, in lesson 5 the workshop asks to show the results of 32/7 and 32.0/7. Will the use of different operators such as float or int give me different results. I attempted in my code, but it resulted in an error. Could you point me in the right direction??
#include <iostream>
#include "stdafx.h"
using namespace std;

int main()
{
    int num1 = 32, num2 = 32.0, num3 = 7;
    int result = num1/num3;
    float result2 = num2/num3;

    cout << result << endl;
    cout << result2 << endl;
    return 0;
}

A:

You have declared all the three numbers num1, num2 and num3 as int, so they will behave as integers. You may probably want num2 to be declared as a float for result2 to store a float value. When two ints are divided, they will result in an int, and after that if you store the result in a float, it will only result in a floating point representation of the integer result. Eg : for result2, num2/num3 will be 32/7 which will be equal to 4 as an integer. Now, since it has to be stored in a float (reading the expression from right to left), it will be typecasted as 4.000000. 

