Hi,
2 ways.
>>
int a,b,c;
if(b)
c = a / b;
else
print " Cannot divide by zero"
OR
c = a / minOne(b);
//it returns a itself if b is zero because minOne() returns non zero values that we passes. If it is zero then it retuns 1
Above methods is to prevent the stoppage of flow of execution.
Regards,
2 ways.
>>
int a,b,c;
if(b)
c = a / b;
else
print " Cannot divide by zero"
OR
c = a / minOne(b);
//it returns a itself if b is zero because minOne() returns non zero values that we passes. If it is zero then it retuns 1
Above methods is to prevent the stoppage of flow of execution.
Regards,
No comments:
Post a Comment