Strange Numbers

Discuss Computer Science and Programming related problems

Moderators:Labib, bristy1588

samiul_samin
Posts:1007
Joined:Sat Dec 09, 2017 1:32 pm
Strange Numbers

Unread post by samiul_samin » Thu Feb 15, 2018 9:20 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?

SYED ASHFAQ TASIN
Posts:29
Joined:Thu Jun 02, 2016 6:14 pm

Re: Strange Numbers

Unread post by SYED ASHFAQ TASIN » Sun Sep 16, 2018 10:16 pm

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.
EARLY TO BED AND EARLY TO RISE,MAKES A MAN HEALTHY,WELTHY AND WISE.[\color]

samiul_samin
Posts:1007
Joined:Sat Dec 09, 2017 1:32 pm

Re: Strange Numbers

Unread post by samiul_samin » Thu Jan 10, 2019 4:03 pm

I have figured out the reason thanks.

SYED ASHFAQ TASIN
Posts:29
Joined:Thu Jun 02, 2016 6:14 pm

Re: Strange Numbers

Unread post by SYED ASHFAQ TASIN » Mon Jan 28, 2019 1:40 pm

What was the mistake(s)?
EARLY TO BED AND EARLY TO RISE,MAKES A MAN HEALTHY,WELTHY AND WISE.[\color]

samiul_samin
Posts:1007
Joined:Sat Dec 09, 2017 1:32 pm

Re: Strange Numbers

Unread post by samiul_samin » Tue Jan 29, 2019 6:10 pm

SYED ASHFAQ TASIN wrote:
Mon Jan 28, 2019 1:40 pm
What was the mistake(s)?
Those was junk memory like undefined array value.Because I gave wrong datatype.

User avatar
emeryhen121
Posts:21
Joined:Fri Jul 16, 2021 6:04 pm

Re: Strange Numbers

Unread post by emeryhen121 » Mon Oct 25, 2021 6:50 pm

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.

Post Reply