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;
}
Answers were Sorted based on User's Feedback
Answer / susie
Answer :
x=10 y=8
Explanation:
Using ^ like this is a way to swap two variables without
using a temporary variable and that too in a single statement.
Inside main(), void swap(); means that swap is a function
that may take any number of arguments (not no arguments) and
returns nothing. So this doesn’t issue a compiler error by
the call swap(&x,&y); that has two arguments.
This convention is historically due to pre-ANSI style
(referred to as Kernighan and Ritchie style) style of
function declaration. In that style, the swap function will
be defined as follows,
void swap()
int *a, int *b
{
*a ^= *b, *b ^= *a, *a ^= *b;
}
where the arguments follow the (). So naturally the
declaration for swap will look like, void swap() which means
the swap can take any number of arguments.
| Is This Answer Correct ? | 4 Yes | 0 No |
what is oop?
main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }
How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?
Code for 1>"ascii to string" 2>"string to ascii"
1 Answers Aricent, Global Logic,
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numbers like 1867,1687,1768 etc are the numbers that match irrespective of the position of the digit. Thus all these numbers qualify fr the lucky draw prize Assume there is no zero digit in any numbers. write a program to show all the possible winning numbers if a "winning number"is passed as an arguments to the function.
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }
how can u draw a rectangle in C
53 Answers Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,