ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
swap two integer variables without using a third temporary
variable?
 Question Submitted By :: A. Sujatha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: swap two integer variables without using a third temporary variable?
Answer
# 1
the best way what i choose is that : if x=89 , y=-88

x^=y^=x^=y;

this line will swap the above numbers......


thank u
 
Is This Answer Correct ?    2 Yes 0 No
Vignesh1988i
 
  Re: swap two integer variables without using a third temporary variable?
Answer
# 2
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("\n ENTER 2 VALUES : ");
scanf("%d%d",&a,&b);
printf("\n THE VALUES BEFORE SORTING : %d,%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\n THE VALUES AFTER SORTING : %d,%d",a,b);
getch();
}
 
Is This Answer Correct ?    2 Yes 0 No
Sidhartha
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks Excel4
Describe advantages and disadvantages of the various stock sorting algorithms Microsoft1
44.what is the difference between strcpy() and memcpy() function? 45.what is output of the following statetment? 46.Printf(“%x”, -1<<4); ? 47.will the program compile? int i; scanf(“%d”,i); printf(“%d”,i); 48.write a string copy function routine? 49.swap two integer variables without using a third temporary variable? 50.how do you redirect stdout value from a program to a file? 51.write a program that finds the factorial of a number using recursion?  3
size maximum allocated by calloc() DELL1
how to implement stack work as a queue?  2
helllo sir , what is the main use of the pointer ,array ,and the structure with the example of a programe  2
how to convert binary to decimal and decimal to binary in C lanaguage  4
Concat two string with most overlapped substring has to remove  "abcd"+ "cdef" = "abcdef  5
what is the difference between. system call and library function? CDAC2
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??  3
6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } after calling swap ,what are yhe values x&y?  2
write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview Satyam2
What does the message "warning: macro replacement within a string literal" mean?  1
What is the most efficient way to count the number of bits which are set in a value?  3
what is the use of #pragma pack, wer it is used? Wipro1
#ifdef TRUE int I=0; #endif main() { int j=0; printf("%d %d\n",i,j); } ADITI2
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 Accenture13
Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed. Scientific-Atlanta2
What is the relation between # and include<stdio.h> HCL3
difference between my-strcpy and strcpy ? Geometric-Software3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com