473,395 Members | 1,949 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,395 software developers and data experts.

c program

i had doubt regrdng this progrm... pls explain..

#include<stdio.h>
void main()
{
int a, b;
printf("enter d value fof a and b");
scanf("%d%d", &a, &b);
printf("%d%d",&b,b);
}

wats d op of this program... pls get soon..
Oct 30 '08 #1
9 1265
JosAH
11,448 Expert 8TB
You wrote 'void main()' which results in undefined behaviour.

kind regards,

Jos
Oct 30 '08 #2
newb16
687 512MB
You wrote 'void main()' which results in undefined behaviour.
Also he forgot code tags, that is by an order of magnitude larger sin.
And let alone printf("%d%d",&b,b) where &b is printing b's address ( if pointer and int are both 32 bit).
Oct 30 '08 #3
donbock
2,426 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. printf("%d%d",&b,b);
}
This format string is incompatible with the arguments: %d is for printing an int; &b is a pointer, b is an int.
Why would you want to print two numbers without any space between them?
Oct 30 '08 #4
JosAH
11,448 Expert 8TB
Also he forgot code tags, that is by an order of magnitude larger sin.
And let alone printf("%d%d",&b,b) where &b is printing b's address ( if pointer and int are both 32 bit).
The OP also didn't write his/her post in English; as a non-native speaker I had to
guess for the meaning of 'wats d op of this program... pls get soon..'.

My crappy-post-o-meter is rising ;-)

kind regards,

Jos
Oct 30 '08 #5
JosAH
11,448 Expert 8TB
I have deleted the OP's other identical thread.

kind regards,

Jos
Nov 1 '08 #6
You wrote 'void main()' which results in undefined behaviour.

kind regards,

Jos

sir ,
actually i want to print memory adress of b & value of b
Nov 2 '08 #7
This format string is incompatible with the arguments: %d is for printing an int; &b is a pointer, b is an int.
Why would you want to print two numbers without any space between them?

actually i wanted print both address and value of b ,
Nov 2 '08 #8
Laharl
849 Expert 512MB
If you want to see what it outputs, I recommend compiling and running this code. For the code itself, I recommend printing the address in hexadecimal and add some whitespace in between the two numbers so you can tell them apart.
Nov 2 '08 #9
donbock
2,426 Expert 2GB
actually i wanted print both address and value of b ,
"%p" is preferred for printing the address of a variable.
Nov 3 '08 #10

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

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
22
by: edgrsprj | last post by:
PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html ...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
11
by: christopher diggins | last post by:
I am wondering if any can point me to any open-source library with program objects for C++ like there is in Java? I would like to be able to write things like MyProgram1 >> MyProgram2 >>...
1
by: Eric Whittaker | last post by:
hi all, im trying to write my first c++ program. a success, but i can't get the window to stay open after user enters input. it just automatically closes. right now the end of my program looks...
9
by: Hemal | last post by:
Hi All, I need to know the memory required by a c program. Is there any tool/utility which can give me the memory usage in terms of DATA segment, TEXT segment, BSS segment etc. I am working...
7
by: ibtc209 | last post by:
I just started programming in C, and I need some help with this problem. Your program will read the information about one MiniPoker hand, namely the rank and suit of the hand’s first card, and...
2
Banfa
by: Banfa | last post by:
Posted by Banfa The previous tutorial discussed what programming is, what we are trying to achieve, the answer being a list of instructions constituting a valid program. Now we will discuss how...
0
amitpatel66
by: amitpatel66 | last post by:
There is always a requirement that in Oracle Applications, the Concurrent Program need to be execute programatically based on certain conditions/validations: Concurrent programs can be executed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.