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   SiteMap shows list of All Categories in this site.
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
What is the subtle error in the following code segment?

      void fun(int n, int arr[])

      {

      int *p=0;

      int i=0;

      while(i++<n)

      		p = &arr[i];

      *p = 0;

}
 Question Submitted By :: Susie
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }
Answer
# 1
Answer :  & Explanation:

If the body of the loop never executes p is assigned no
address. So p remains NULL where *p =0 may result in problem
(may rise to runtime error “NULL pointer assignment” and
terminate the program).
 
Is This Answer Correct ?    0 Yes 0 No
Susie
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above HCL1
main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }  1
1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?  1
Program to find the largest sum of contiguous integers in the array. O(n)  7
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };  1
What are the files which are automatically opened when a C file is executed?  1
main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }  1
main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }  1
how can u draw a rectangle in C Wipro31
How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.  1
#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }  1
Write a C function to search a number in the given list of numbers. donot use printf and scanf Honeywell4
main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }  1
#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }  1
main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }  1
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }  1
main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }  1
Is the following code legal? typedef struct a { int x; aType *b; }aType  1
void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }  1
int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }  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