I'm very curious about how does the "term" variable work in the first line of code when it codes: double pi = 0.0, term;
I also am unable to run this code on VSCode IDE Error Code C4578
I can't seem to find an answer on Google, so I came here. On the error of running the code, I tried to change numbers (adding decimal places) because it says its a data conversion problem with abs(). I think its something with abs() only outputing int datatype, is there anyway to fix it?
Thank u so much if you are seeing this, its my first time coding ;)
In
double pi = 0.0, term;,pi = 0.0andtermare separate items. Equivalent code isdouble pi = 0.0;, which definespito be adoubleand initializes it to zero, anddouble term;, which definestermand does not specify an initial value for it.The error “'initializing': conversion from 'double' to 'int', possible loss of data'” is from the line
int places = 10.0;, which specifies adoublevalue,10.0, for anintobject,places. To eliminate the warning, change this toint places = 10;.In
C,absis a function for theinttype. The fact that this code uses it with adoubleoperand,term, indicates this is C++ code, and the file name,L2.1-2.3.cpp, also indicates this is C++ code. You seem to have requested your compiler to compile it as C code, which is why it gives you the message “'abs': conversion from 'double' to 'int', possible loss of data”. You should change whatever setting is telling your compiler to compile this as C code.