My console app looks like that.
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a, b;
cin>>a>>b;
cout<<"% "<<a%b<<endl<<"fmod "<<fmod(a,b)<<endl;
system("pause");
return 0;
}
I’m newbie to C++ and I got 2 questions:
- Writing this application on VS. Why do I need to include “stdafx.h”? Is there any requirement? What is this?
- Is there any difference between
fmodand%? Getting exactly same results for them:

Thx in advance..
Because the default project setting says you need precompiled header (See this).
You can disable this manually. Select Not Using Precompiled Headers as shown in the image below:
Yes.
%cannot operate on floating-pointer numbers, whilefmodcan.finfmodindicates floating-point.Try this: