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 |
study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above
main() { char *p; p="Hello"; printf("%c\n",*&*p); }
what is a function prototype?
What is character constants?
What is action and transformation in spark?
Why c++ is called c++ and not c+?
how to make program without <> in library.
What is the difference between %d and %i?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
Write a simple code fragment that will check if a number is positive or negative.
what are the files which are automatically opened when a c file is executed?
What character terminates all strings composed of character arrays? 1) 0 2) . 3) END