473,471 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

2 New Member
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 1431
arnaudk
424 Contributor
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 Recognized Expert Contributor
%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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.