473,322 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

b o/p is 0,how it will Come?

main()
{
int a=300,b,c;
if(a>=400)
b=300;
c=200;
printf("\n%d %d",b,c);
}

i hav done this program,but i got b=0,c=200.how the b value is 0,plz explain the reason.
May 19 '08 #1
2 1428
arnaudk
424 256MB
1) Why isn't this post in the C/C++ forum?
2) You forgot braces after the if statement. This means only the next statement after if() is executed. The value of b is 0 because a is not grater than or equal to 400, so the statement b=300 after if() is not executed. Corrected version:
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3. int a=300,b,c;
  4. if(a>=400)
  5. {
  6.   b=300;
  7.   c=200;
  8. }
  9. printf("\n%d %d",b,c);
  10. }
  11.  
Note some other things. If a is smaller than 400, then b and c will be uninitialized. This does not mean that they will always be zero, they appear to be because you have implicitly cast them to double in your print statement when they are in fact int. The correct print statement is printf("%i %i\n",b,c); then you will see you get a large negative number corresponding the minimum value of an integer on your system (because they are uninitialized).
May 19 '08 #2
Laharl
849 Expert 512MB
%d is not a double, it's a signed integer. For a double, you would use %f. Also, just because it's uninitialized doesn't mean you would get INT_MIN. You would get whatever garbage value happened to be in that memory during the last time the memory was used. This might be INT_MIN, it might be 0, it could be anything.
May 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Monsey Computers | last post by:
In some searches on our web site the items will come back with a different dollar sign than the US $ symbol why is that? MC *** Sent via Developersdex http://www.developersdex.com *** Don't...
100
by: Peter | last post by:
Company thought DB2 will be better than Oracle. The bottom line is when you do select, the system crash. I think it may take 4-5 years for DB2 to reach Oracle standard. Peter
4
by: JackSu | last post by:
Will someday all the application on microsoft platform become .NET only?
1
by: Faree | last post by:
Hi all, can any one come up with the code that display the images from the folder.but image should be changed for every 5 seconds.can any one com with this code. or suggest me the way to do...
33
by: DFS | last post by:
An application I wrote has been deployed on Citrix, and the Citrix admin tells me all users run the same .mde file. There aren't a lot of concurrent users, but even 2 could be cause for concern. ...
3
by: Antonio Policelli | last post by:
Hello, please tell me how to do this.. I have a web page that a user can manipulate and work with a database object. it is not important what that is but for the user to start on a new object,...
5
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
6
by: Aaron Bertrand [SQL Server MVP] | last post by:
Based on a couple of recent discussions I've had on this topic, I posted a brief article last night: "How long will classic ASP be supported?" http://www.aspfaq.com/2545 Please let me know...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.