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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
#include<stdio.h>
void fun(int);
int main()
{
int a;
a=3;
fun(a);
printf("\n");
return 0;
}
void fun(int i)
{
  if(n>0)
  {
    fun(--n);
    printf("%d",n);
    fun(--n);
   }
}  the answer is 0 1 2 0..someone explain how the code is
executed..?
 Question Submitted By :: Geetha_raj2007
I also faced this Question!!     Rank Answer Posted By  
 
  Re: #include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?
Answer
# 1
for example :
Here a is three(3).
 
calling  fun(3) in main function.
 FUN(3) {
    calling fun(2) {
	calling fun(1)  {
  	    calling fun(0) {
		N>0 found.
            }
	    printed 0				
            calling second fun(-1) {
		N>0 found. 
            }
        }
	printed 1					
        calling second fun(0) {
       	    N>0 found.
        }
    }
     printed 2		
     calling second fun(1) {
	 calling fun(0) { 
	     N>0 found.
         } 
	 printed 0		
         calling second fun(-1) {
 	     N>0 found.
         } 
     }
 }
 
Is This Answer Correct ?    3 Yes 1 No
Siva Kumar
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }  1
main() { char not; not=!2; printf("%d",not); }  1
Is the following code legal? typedef struct a { int x; aType *b; }aType  1
main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }  1
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }  1
main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000 HCL1
Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?  1
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }  1
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }  1
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. Microsoft14
#define SQR(x) x * x main() { printf("%d", 225/SQR(15)); } a. 1 b. 225 c. 15 d. none of the above HCL1
how to delete an element in an array  1
main() { int i=5,j=6,z; printf("%d",i+++j); }  1
void main() { int const * p=5; printf("%d",++(*p)); }  1
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }  1
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);  1
void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }  1
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }  1
What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;  1
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }  1
 
For more C Code 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