When I run the code below
int main(int argc,char *argv[]) {
    double n = 2E-1;
    printf("%d",n);
}
When I run the code it prints a weird number instead of 0.2(2E-1).
When I run the code below
int main(int argc,char *argv[]) {
    double n = 2E-1;
    printf("%d",n);
}
When I run the code it prints a weird number instead of 0.2(2E-1).
What does the constant E do in the c language
The documentation for floating-point constants is here.
The form 1e2 or 1E2 means 1 times ten to the power of 2, and you're perfectly correct that 2E-1 means 2 times ten to the power of -1, or 0.2.
It's based on the scientific E notation linked by Eugene.
When I run the code it prints a weird number
That's just because you used the wrong format specifier. These are documented here, and you can see you should use one of eEfFgG for doubles.
In C language, for double, the format specifier is %lf
So, if you use %lf then it will print n as 0.200000
And if you use %g or %G (as supported data types are float, double) then the output will be 0.2