is it possible?? I want to get result is int or not??Code:if((first/second)!=int)
because result can be float..
is it possible?? I want to get result is int or not??Code:if((first/second)!=int)
because result can be float..
Last edited by koyboy; 05-24-2008 at 08:32 AM.
I think this is how it will be done. Keep in mind that 'first' and 'second' should be int for this.Code:if((first%second)!=0)
Don't use my code if its a nuclear project you're doing though, because 70% of my code is wrong.
Last edited by abh!shek; 05-24-2008 at 08:38 AM.
thanks for reply
C is a strongly typed language. If you divide an int with an int, you will get an integer back and nothing else.
The result will never be a float UNLESS you divide an integer with a float in which case you WILL get a float back.
If you want to check if it can be represented in an integer (ie, no decimals), then you can try something like
first % (int)first == 0
I know it.. but result is false..Like this:
1)first and second value is random (Example first:15 second:10)
2)ask user first/second
3)if user enter 1 its correct in programming but it isnt correct in real math..
so I want to create first and second value which can be something that is divisible by one another..
I write like this and thats ok...
and if I ask first/second, result is exactly int in real and in programming and first%second=0Code:second = (rand()%99)+1 do{ first = second * ((rand()%10)+1); }while(first>=100);
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Are first & second defined as ints or as floats or doubles?
@cpjust in think, they are all int, since they are generated by rand as per what Op says.
ssharish