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 |
write a simple calculator c program to perform addition, subtraction, mul and div.
0 Answers United Healthcare, Virtusa,
how to concatenate the two strings
How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.
In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }
Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector
main() { printf("%x",-1<<4); }
Write a single line c expression to delete a,b,c from aabbcc
how can i cast a char type array to an int type array
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }
how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.
0 Answers Mbarara University of Science and Technology,
Write a C program to print look and say sequence? For example if u get the input as 1 then the sequence is 11 21 1211 111221 312211 12112221 .......(it counts the no. of 1s,2s etc which is in successive order) and this sequence is used in run-length encoding.