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
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
	int x=5,y=10;
	swap1(x,y);
	printf("%d %d\n",x,y);
	swap2(x,y);
	printf("%d %d\n",x,y);
}

int swap2(int a,int b)
{
	int temp;
	temp=a;
	b=a;
	a=temp;
	return;
}

what are the outputs?
 Question Submitted By :: Naveed
I also faced this Question!!     Rank Answer Posted By  
 
  Re: #define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?
Answer
# 1
10 5
5 10
 
Is This Answer Correct ?    1 Yes 1 No
Mannucse
[Kiona]
 
  Re: #define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?
Answer
# 2
10 5
10 5
 
Is This Answer Correct ?    2 Yes 0 No
Goodhunter
 
 
 
  Re: #define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?
Answer
# 3
10 5
5  5
 
Is This Answer Correct ?    1 Yes 0 No
Chitra
 
  Re: #define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?
Answer
# 4
Result of the above program will probably be sth like :
compile error `return' with no value, in function returning
non-void
or
function swap2(...) should return a non-void value.
thats because from the erroneous code YOU CANT PREDICT what: 
return;
in swap2 function was about to return.
It may sound that Im picking, but as an interviewer myself,
I have to say it is CRUCIAL on an interview to pinpoint
errors in the code, NEVER assume that its just a
misspelling, some of those errors are, some of them aren't
and are there to check if you read code thoroughly, its
always better to point such things.

Assuming the code was right and the swap2 signature was
void swap2(int a, int b)
code result will be :
10 5
10 5
switching values of a and b in swap2 doesnt affect x and y
values in program because they are being passed BY VALUE to
swap2.
 
Is This Answer Correct ?    1 Yes 0 No
Jaroosh
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What should not contain a header file?  2
main() {int a=200*200/100; printf("%d",a); } TCS7
What are the languages are portable and platform independent?Why they are like that? Excel1
a 'c' program to tell that the set of three coordinates lie on a same line Persistent1
How many types of linked lists what are they? How many types of data structures? BSNL5
write a programme that inputs a number by user and gives its multiplication table.  2
What is structure padding ? HP2
what is the diff b/w static and non static variables in C. Give some examples plz. Wipro2
give one ip, find out which contry Google4
int i =10 main() { int i =20,n; for(n=0;n<=i;) { int i=10 i++; } printf("%d", i); HCL5
What is a symbolic constant?  1
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?  3
difference between i++* and *++i IBM3
Determine if a number is a power of 2 at O(1).  1
C program to perform stack operation using singly linked list  3
fn f(x) { if(x<=0) return; else f(x-1)+x; } HCL3
write a c program to check weather a particluar bit is set or not? IBM4
plz answer..... a program that reads non-negative integer and computes and prints its factorial  2
Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2) Subex2
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 IBM3
 
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