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                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
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 do in place reversal of a linked list(singly or 
doubly)?
 Question Submitted By :: Uttejana
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to do in place reversal of a linked list(singly or doubly)?
Answer
# 1
int reverse()
{
 node *r,*s,*q;
 s=NULL;
 q=p;
while(q!=NULL)
 {
  r=q;
 q=q->link;
 r->link=s;
 s=r;
 }
 p=r;
return;
}
this is reverse fun for single linked list.
 
Is This Answer Correct ?    4 Yes 4 No
Divakar & Venkatesh
 
  Re: how to do in place reversal of a linked list(singly or doubly)?
Answer
# 2
rev()
{
struct node *a1,*a2,*a3;
if(start->next==NULL)    /*Only one element exists*/
    return;
a1=start;
a2=a1->next;
a3=a2->next;
a1->next=NULL;
a2->next=a1;
while(a3!=NULL)
{
a1=a2;
a2=a3;
a3=a3->next;
a2->next=a1;
}
start=a2;
}
 
Is This Answer Correct ?    0 Yes 0 No
Ashish Gupta
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
#define MAX(x,y) (x) > (y) ? (x) : (y) main() { int i = 10, j = 5, k = 0; k = MAX(i++, ++j); printf("%d %d %d", i,j,k); } what will the values of i , j and k? } NDS9
value = 0xabcd; for (loop = 1; (value >> 1) & 1 | loop & 1; loop++) { foo(); if (loop & 1) value >>= 1; } how many times is foo() executed? Google5
struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator?? Verifone8
4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above Accenture4
main is a predefined or user define function if user defined why? if predefined whay? TCS2
When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?  2
Write a program or provide a pseudo code to flip the 2nd bit of the 32 bit number ! (Phone Screen) NetApp1
main() {int a=200*200/100; printf("%d",a); } TCS7
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?  5
What does extern mean in a function declaration?  2
Which of the following about automatic variables within a function is correct ? a.its type must be declared before using the variable b.they are local c.they are not initialised to zero d.they are global. TCS3
write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.  4
What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1; TCS10
Write a program to accept a character & display its corrosponding ASCII value & vice versa?  4
What does a run-time "null pointer assignment" error mean?  2
write the program for maximum of the following numbers? 122,198,290,71,143,325,98  4
Describe advantages and disadvantages of the various stock sorting algorithms Microsoft1
What is a class?  2
WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS  4
a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? a.infinite b.5 c.4 d.6 TCS5
 
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