Strange Numbers
Moderators:Labib, bristy1588
-
- Posts:1007
- Joined:Sat Dec 09, 2017 1:32 pm
When I run a usual C programme by codeblock to find the area of a circle,Iget exact value if I put any number.But when I input abcde or any other letter as the radius ,the compiler shows strange numbers.It is different according to inputs.It is not base 16 numbers.What are those strange numbers?
-
- Posts:29
- Joined:Thu Jun 02, 2016 6:14 pm
Re: Strange Numbers
Are you saying that you are getting the actual area by defining radius as 'r' ?
Got that right?But I just tested and its running fine,have you used float?Define 'pi'?Have you used '%f' as format specifier?
If you yet suffering the problem,please share the programme .Then its going to be easy what's going on.
Thank you.
Got that right?But I just tested and its running fine,have you used float?Define 'pi'?Have you used '%f' as format specifier?
If you yet suffering the problem,please share the programme .Then its going to be easy what's going on.
Thank you.
EARLY TO BED AND EARLY TO RISE,MAKES A MAN HEALTHY,WELTHY AND WISE.[\color]
-
- Posts:1007
- Joined:Sat Dec 09, 2017 1:32 pm
Re: Strange Numbers
I have figured out the reason thanks.
-
- Posts:29
- Joined:Thu Jun 02, 2016 6:14 pm
Re: Strange Numbers
What was the mistake(s)?
EARLY TO BED AND EARLY TO RISE,MAKES A MAN HEALTHY,WELTHY AND WISE.[\color]
-
- Posts:1007
- Joined:Sat Dec 09, 2017 1:32 pm
Re: Strange Numbers
Those was junk memory like undefined array value.Because I gave wrong datatype.
- emeryhen121
- Posts:21
- Joined:Fri Jul 16, 2021 6:04 pm
Re: Strange Numbers
There are various reasons why this could be happening.
Have you used float?
Check the datatypes
Check any missing symbols
Have you defined the array? If yes. How have you defined it?
Have you used '%f' as a format specifier?
Another thing, you should always share your code for this sort of work, sometimes the problem is very small that gets ignored by the human eye. Multiple opinions can solve it. You can find good examples here: https://mytutorsource.com/blog/fastest- ... arn-maths/. Moreover, it is easier to identify the problem if it is in front of you.
Have you used float?
Check the datatypes
Check any missing symbols
Have you defined the array? If yes. How have you defined it?
Have you used '%f' as a format specifier?
Another thing, you should always share your code for this sort of work, sometimes the problem is very small that gets ignored by the human eye. Multiple opinions can solve it. You can find good examples here: https://mytutorsource.com/blog/fastest- ... arn-maths/. Moreover, it is easier to identify the problem if it is in front of you.