HOW TO SWAP TWO NOS IN ONE STEP?
Answers were Sorted based on User's Feedback
Answer / shiva kumar
void main()
{
int a,b;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
b=a+b-(a=b);
printf("%d %d ",a,b);
}
Is This Answer Correct ? | 28 Yes | 7 No |
Answer / sasikumar
main()
{
int a,b,c;
printf("enter two no's :");
scanf("%d%d",&a,&b);
c=a^=b^=a^=b;
printf("%d",c);
}
Is This Answer Correct ? | 6 Yes | 6 No |
Answer / vijay
#include<stdio.h>
main()
{
int a=5,b=9;
printf("%d %d \n",a,b);
a^=b^=a^=b;
printf("%d %d \n",a,b);
}
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / venkatesh sabinkar
#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=2,t;
clrscr();
printf("a=%d,b=%d",a,b,b=t,a=b,t=a);
getch();
}
Is This Answer Correct ? | 3 Yes | 4 No |
Answer / z
Trick question: the phrase "one step" is undefined.
Example: how many steps are there in the following statement?
a = ++b;
Is This Answer Correct ? | 0 Yes | 1 No |
amaresh@Hare-Krishna:~$ cat swp.c
#include<stdio.h>
int
main(){
int a=5,b=6; // Compile using gcc -Wall
#ifdef DEBUG // to avoid compiler warnings
a ^=b^=a^=b;
#endif
printf("value of a is %d and b is %d\n",a,b);
return 0;
}
Is This Answer Correct ? | 2 Yes | 4 No |
which is the best site or book for learning C...and i need the content for C..how to get the good programming skills....? can plz suggest me....
How to define structures? ·
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
How to set a variable in the environment list?
what is the use of using linked list and array?
What are the various topologies? Which one is the most secure?
WAP to accept first name,middle name & last name of a student display its initials?
write a program to compare 2 numbers without using logical operators?
The file stdio.h, what does it contain?
Q-1: Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college.
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.