How to swap two variables, without using third variable ?
Answers were Sorted based on User's Feedback
Answer / er
Only #2 will work. The others may over/under flow.
| Is This Answer Correct ? | 83 Yes | 129 No |
Answer / ankush
using ref keyword we can swap 2 number's
emaple
class swap
{
public void add(ref int a,ref int b)
{
int z;
z=a;
a=b;
b=z;
}
}
class swapdemo
{
static void main()
{
int x=10,y=5;
ankush obj=new ankush();
Console.writeline{"befor value's"+a+","+b};
obj.swap(ref x, ref y);
Console.writeline("after values"+a+","+b);
}
}
| Is This Answer Correct ? | 13 Yes | 72 No |
How we print the table of 2 using for loop in c programing?
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
#include<stdio.h> int main() { int a=3,post,pre; post= a++ * a++ * a++; a=3; pre= ++a * ++a * ++a; printf("post=%d pre=%d",post,pre); return 0; }
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }
29 Answers IBM, TCS, UGC NET, Wipro,
Cau u say the output....?
posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };
main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }
#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }
main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above