We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,645 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how a compiler works?

Look into this code:

#include <stdio.h>
main()
{
int p,n,r;
float si;
scanf("%d %d %d", &p, &n, &r);
si=p*n*r/100;
printf("SI = %f", si);
}

Output of this program is
100
100
100
SI = 169.00000
and also this:

#include <stdio.h>
main( )
{
int p, n ;
float r, si ;
printf ( "Enter values of p, n, r" ) ;
scanf ( "%d %d %f", &p, &n, &r ) ;
si = p * n * r / 100 ;
printf ( "%f" , si ) ;
}

Output of this program is
100
100
100
SI = 1000

How a compiler is understanding these codes?
Why the answer is not correct for the first program?

Can any one help me out with a compiler meaning?

7
Contributors
12
Replies
1 Day
Discussion Span
9 Months Ago
Last Updated
13
Views
shankarz
Newbie Poster
12 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

What compiler are you using?

deceptikon
Challenge Accepted
Administrator
3,426 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 56

Let's see... I'm going to troll a bit here. From the name Shankar, I'm guessing he's Indian. With that, I'm going to assume that he's using our beloved Turbo C++ in 16 glorious bits. I'm going to further guess that there's an overflow error lurking about here somewhere.

DeanMSands3
Posting Whiz
310 posts since Jan 2012
Reputation Points: 80
Solved Threads: 42
Skill Endorsements: 1

Try outputting the values you input to see if they are correct.
Since you are probably using, as DeanMSands3 supposes, Turbo (I'm sure he's correct) find out what the largest integer is you can have in your compiler.

WaltP
Posting Sage w/ dash of thyme
Team Colleague
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 36

hey DeanMsands3 , It is not good that how rudely you are talking here. If any body is using Turbo or any thing, then you can't say(insult) that he is indian or american or whatever. It is a very nice forum and very good repo in India also. But, Having this type of mocking at Indians IS REALLY HURTING and can be painful. Any body can use any thing what ever he wants and actually need, So I request you "DON'T GUESS FROM THE COMPILER THAT WHICH NATIONALITY A PERSON HAS".

THANKS.

I_m_rude
Deleted Member

no nitin1 actually india is really below the curve bcoz in most of the colleges r using turbo c .so surely everyone will make us embrassing

rithish
Posting Whiz in Training
268 posts since Apr 2011
Reputation Points: 23
Solved Threads: 9
Skill Endorsements: 0

@ritish I know this as I hope you also know that I am Indian too. But, the respect for the country is there in us. DeanMsand3 has said that thing in a too insultive way. It is okay if indians use that but ANYONE can't be insultive for that. I hope you are getting what i am trying to say.

I_m_rude
Deleted Member

yeah he is insulting iam too an indian from chennai.its upto them they may have bad feeling about us.but we cant fight with them

rithish
Posting Whiz in Training
268 posts since Apr 2011
Reputation Points: 23
Solved Threads: 9
Skill Endorsements: 0

better use code blocks with mingw shankar

rithish
Posting Whiz in Training
268 posts since Apr 2011
Reputation Points: 23
Solved Threads: 9
Skill Endorsements: 0

So I request you "DON'T GUESS FROM THE COMPILER THAT WHICH NATIONALITY A PERSON HAS".

It looks to me like he guessed India from the OP's name, and then further speculated the compiler based on previous observations (an observation I've made as well). I don't think you should feel insulted, but I'll ask two questions that may calm your anger:

  1. Is Shankar an uncommon name in India or exceptionally common in another country that you would be insulted if it were associated with India?

  2. Is Turbo C not the most commonly used compiler in educational institutions by far in India?

If you answered yes to either of those then you can take offense and address the issue privately with DeanMSands3. Otherwise, I'd suggest growing some thicker skin and not taking offense at the first potentially negative mention of your country. That's how pointless wars are started.

deceptikon
Challenge Accepted
Administrator
3,426 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 56

@james sir,

This is a very nice thing which you said. I know shankar is a common name and TC is used alot here. But, Sometimes many things hurt you which may look "non-hurting" to anyone else. Okay! you are a great person for me and I request you limitless.
thanks for making me understand. :)

I_m_rude
Deleted Member

Im Indian too. And yeah turbo C is the most common IDE used here. But lets not takes these seriously guys, we are here to learn and share. So peace guys.
And for shankar, please use MinGW compilers with codeblocks. It will help you a lot. :)

np complete
Posting Whiz
385 posts since Sep 2010
Reputation Points: 18
Solved Threads: 36
Skill Endorsements: 0

okies. thanks for your suggestions. And shankar you can dev C++ or codeblocks. they are quite good for you.

I_m_rude
Deleted Member

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1150 seconds using 2.74MB