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

plzzz explain me this stuff?

main()
{
void swap();
int x=10,y=8;
swap(&x,&y);
printf("x=%d y=%d",x,y);
}
void swap(int *a, int *b)
{
*a ^= *b, *b ^= *a, *a ^= *b;
}
Answer:
x=10 y=8
Jun 26 '14 #1
5 979
donbock
2,426 Expert 2GB
Can you tell me what ^= does?
Can you tell me what the commas do in the last line of code?
Jun 26 '14 #2
i am asking u same :(
Jun 26 '14 #3
donbock
2,426 Expert 2GB
Please refer to the rules regarding Posting Homework or Coursework Questions and Answers. I don't think I'm permitted to merely give you the answer. I can walk you through it, but you need to be actively involved.
Jun 26 '14 #4
weaknessforcats
9,208 Expert Mod 8TB
What programming language is this?

If the answer is x=10 and y = 8 and at the beginning x =10 and y=8, then this code doesn't work.
Jun 26 '14 #5
donbock
2,426 Expert 2GB
Perhaps you meant the printed result is "x=8, y=10".

General problems with your code that don't actually involve its function.
  • Function main should return int. This means you need a return statement at the end of main.
  • The declaration of swap should be before the beginning of main; and it should be a function prototype that specifies the types of the arguments.
  • The printf format string should end with a newline because stdout is typically a buffered stream.
Jun 26 '14 #6

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

Similar topics

11
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
2
by: Abhish | last post by:
HI All ,:) I am a VC++ programmer,and some time My <b>Acumen</b> ask Microsofts VC++ (Visual Studio VC++ 6.0 )complier to complile my <b>senseless programs </b> ! :) <i><b> See what I have...
2
by: Ravi Uday | last post by:
Hi, Can anybody explain this.. #define LIST_DESTROY(a) list_destroy(a) #define LIST_ENQUEUE(a, b, c) list_enqueue(a,b,c) #define LIST_REMOVE(a, b, c) list_remove(a,b,c) etc...
3
by: Michael Tsai | last post by:
Hi, It said that IIS 6 use HTTP.sys as the front end for handling HTTP request, and pass ASP.NET requests to w3wp.exe, but after some simple experiments, I found the security settings (e.g....
3
by: Jan Nielsen | last post by:
Hi I am working with rowfilters in dataviews. I would like to filter for empty fields (= null value in the database) I found this sentence on msdn: **************** To return only those columns...
24
by: muttaa | last post by:
i've a code snippet below: for(;0;) printf("Gud Morning"); when this is run,i get the "gud morning" message printed,eventhough the
1
by: Andrew | last post by:
Hello, friends, I am implementing web app security using asp.net 1.1, and I found the following source code from Yahoo! Mail login page: <form method="post"...
6
dmjpro
by: dmjpro | last post by:
how can i explain this ......... class S1 { static void Static() { System.out.println("Here i m ..."); } }
2
by: gayathriram | last post by:
class test { static void show(params object b) { console.WriteLine(b.GetType().FullName); console.WriteLine(b.length); console.WriteLine(b); }...
1
by: John Saunders | last post by:
"Joseph Geretz" <jgeretz@nospam.comwrote in message news:ehHM86fDJHA.4428@TK2MSFTNGP06.phx.gbl... I would suggest that you get Reflector and take a look at the code. But I bet it calls you...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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...
0
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.