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
HOW TO SWAP TWO NOS IN ONE STEP?
 Question Submitted By :: Tuhinkantibhandari
I also faced this Question!!     Rank Answer Posted By  
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 1
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 ?    2 Yes 3 No
Sasikumar
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 2
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 ?    9 Yes 1 No
Shiva Kumar
 
 
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 3
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 2 No
Amaresh Chandra Das
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 4
step 1.
a=b,b=a
 
Is This Answer Correct ?    0 Yes 15 No
Sasa
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 5
#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 ?    3 Yes 1 No
Vijay
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 6
#define SWAP(x,y) int t;t=x;x=y;y=t;
 
Is This Answer Correct ?    2 Yes 6 No
Ashik
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 7
#define swap(a,b) a^=b^=a^=b;
 
Is This Answer Correct ?    3 Yes 1 No
Ashik
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 8
#include(stdio.h);
#include(stdlib.h);
void main()
{
int a=10,b=20;
swap(a,b);
a=b&b=a;
printf("%d%d",a,b);
}
 
Is This Answer Correct ?    1 Yes 2 No
N.ramesh
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 9
(a=a-(b=(a=a+b)-b));
 
Is This Answer Correct ?    4 Yes 0 No
Rajkumar
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 10
int a=5,b=2;
printf("%d %d");


execute the pgm deftly swap wil tak place.......
 
Is This Answer Correct ?    0 Yes 6 No
Priya
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 11
#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 ?    0 Yes 2 No
Venkatesh Sabinkar
 
  Re: HOW TO SWAP TWO NOS IN ONE STEP?
Answer
# 12
#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 ?    1 Yes 0 No
Venkatesh Sabinkar
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is the advantage of function pointer TCS10
what is the output of the following program and explain the answer #include<stdio.h> exp() { main(5) } main(int a) { printf("%d",a); return; } Satyam3
Write an implementation of “float stringToFloat(char *str).” The code should be simple, and not require more than the basic operators (if, for, math operators, etc.). • Assumptions • Don’t worry about overflow or underflow • Stop at the 1st invalid character and return the number you have converted till then, if the 1st character is invalid return 0 • Don’t worry about exponential (e.g. 1e10), instead you should treat ‘e’ as an invalid character • Write it like real code, e.g. do error checking • Go though the string only once • Examples • “1.23” should return 1.23 • “1a” should return 1 • “a”should return 0 Qualcomm5
whether itis a structured language? 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
i want to have a program to read a string and print the frequency of each character and it should work in turbo c  2
What is meaning of "Void main" in C Language. TCS8
class foo { public: static int func(const char*& p) const; }; This is illegal, why? Google6
Write code for initializing one dimentional and two dimentional array in a C Program? Deshaw5
what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these IBM2
Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?  2
what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }  3
what is the use of call back function in c?tell me with example  1
Write a program that accepts a string where multiple spaces are given in between the words. Print the string ignoring the multiple spaces. Example: Input: “ We.....Are....Student “ Note: one .=1 Space Output: "We Are Student" IBM4
difference between i++* and *++i IBM3
Given an unsigned integer, find if the number is power of 2?  3
what is array? HCL22
how to add numbers without using arithmetic operators. TCS10
what is the difference between c and java?  1
Write a C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….  1
 
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