I tried writing a code, which is supposed to calculate 4 - 4/3 + 4/5 - 4/7 + 4/9 +... but it keeps printing "3" as the answer.
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int main()
{
    int s=0,a,n;
    cin>>n;
    for(int i=0 ; i<=n ; i++)
    {
        a=(4/((2*i)+1))*pow(-1,i);
        s=s+a;
    }
    cout<<s;
    return 0;
}
 
     
     
    