Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new

 Categories  >>  Software  >>  Programming Languages  >>  C

 C Interview Questions C++ Interview Questions VC++ Interview Questions Delphi Interview Questions Programming Languages AllOther Interview Questions
Question
```wat are the two methods for swapping two numbers without
using temp variable??```
Question Submitted By :: Vishnu
I also faced this Question!!     Rank Answer Posted By

Re: wat are the two methods for swapping two numbers without using temp variable??
# 1
main()
{
int a=4;b=6;
printf("Before swapping: a=%d, b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swapping: a=%d, b=%d",a,b);
}

 Is This Answer Correct ? 10 Yes 1 No
Vijayakumar Kanagasabai

Re: wat are the two methods for swapping two numbers without using temp variable??
# 2
int a=4,b=6;
printf("Before swapping: a=%d, b=%d",a,b);
a=a^b;
b=a^b;
a=a^b;
printf("After swapping: a=%d, b=%d",a,b);
}

 Is This Answer Correct ? 1 Yes 0 No
Saida

  Question Asked @ Answers Other C Interview Questions write a program that eliminates the value of mathematical constant e by using the formula e=1+1/1!+1/2!+1/3!+ Reliance 1 write a program in c language to print your bio-data on the screen by using functions. IBM 1 What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value Accenture 3 why programming language C is still used in operating system's kernel?? Wipro 1 consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; case 3:sum*=2; break; default:sum=0;} if n=2, what is the value of sum a.0 b.6 c.3 d.none TCS 7 What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these IBM 3 void main() { char c; while(c=getchar()!='\n') printf("%d",c); } o/p=11 why? Wipro 8 the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................ IBM 12 what is a c-language.what is do. HCL 4 how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 plz plz... 3 i=20,k=0; for(j=1;j