Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Interview Questions and Answers 2012

0 comments Posted by Unknown at 01:09
PHP Interview Questions
  

  How To Find a Specific Value in an Array? 

  There are two functions can be used to test if a value is defined in an 
  array or not: 

  array_search($value, $array) - Returns the first key of the matching 
  value in the array, if found. Otherwise, it returns false. 

  in_array($value, $array) - Returns true if the $value is defined in 
  $array. 

  

  

  Here is a PHP script on how to use arrary_search(): <?php 

  $array = array("Perl", "PHP", "Java", "PHP");

  print("Search 1: ".array_search("PHP",$array)."\n");

  print("Search 2: ".array_search("Perl",$array)."\n");

  print("Search 3: ".array_search("C#",$array)."\n");

  print("\n");

  ?>
This script will print: Search 1: 1

  Search 2: 0

  Search 3:

  
Read More »

Solved C Apptitude

0 comments Posted by Unknown at 14:34

 C Apptitude

Predict the output or error(s) for the following:
15. #include
main()
{ char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
Answer:
77
Explanation:
p is pointing to character '\n'. str1 is pointing to character 'a' ++*p. "p is pointing to '\n' and that is incremented by one." the ASCII value of '\n' is 10, which is then incremented to 11. The value of ++*p is 11. ++*str1, str1 is pointing to 'a' that is incremented by 1 and it becomes 'b'. ASCII value of 'b' is 98.
Now performing (11 + 98 – 32), we get 77("M");
So we get the output 77 :: "M" (Ascii is 77).
Read More »

C Aptitude Questions and Answers

0 comments Posted by Unknown at 19:00
Predict the output or error(s) for the following:

1.    void main()
{

            int  const * p=5;

            printf("%d",++(*p));

}


Answer:
Compiler error: Cannot modify a constant value.
Explanation:   p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
Read More »

C language Basic Questions and Answers

0 comments Posted by Unknown at 18:58

 What is C language?



Answers : The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages. C is prized for its efficiency, and is the most popular programming language for writing system software, though it is also used for writing applications.

Read More »
 

© 2011. All Rights Reserved | Interview Questions | Template by Blogger Widgets

Home | About | Top