+ 2
Can you check for decimals in c++?
I want an if statement that only activates if a variable has decimals.
2 Respuestas
0
You can see if a number is a float using algorithm and abs. Is this what you mean?
or your variable could be a string and use a for loop and if statement to see if char == .
test=0
string x="12.3"
for (int i =0;i<x.length();i++)
{if (x[i]=='.')
{test=1;}}
if (test==1)
{//Whatever code you wanted}
0
What you wrote that is not showing decimals show us the code bro.