Friday, April 27, 2012

C interview basic questions and answers for freshers

Latest collection of interview questions on C for freshers. Find output type c interview question involving string concept.


What is Output of following c snippet?
int main(){
   char *s="Abhas";
   printf("%s",s+ 2); 
   getch();
}
Answer:
has
Explanation: In the above program role of %s is to display the string whose address is passed as an argument. This is how a standard printf statement works in c language. Now since we have passed s + 2 as an argument therefore first value of this expression is evaluated. Here ‘s’ would refer to address of first character in string ‘s’. Now printf would get address of third character (address of first character + 2) as argument so it will display the string starting from third position.  Hence output would be ‘has’.

50 C Interview Questions Answers
Logical C Interview Questions Answers

Find more objective c interview questions answers. Download latest pdf on c interview questions and answers, Test your c skills. 

Free download c interview programs as pdf

Simple C Interview questions and definitions

Read more related posts below.


No comments:

Post a Comment