Saturday, May 24, 2008

Some more questions

Interview questions:

                         

Porting

  1. Share some of your experiences of porting problems you encountered
  2. What is meant by 32 bit OS/ 64 bit OS? What is the size of int, long , int*, char* in 32 bit OS and 64 bit OS?
  3. Can there be any potential problem in the following code :

// there is no include statement

main()

{

    char* p = (char*) malloc(100);

    strcpy(p,”Hello World”);

}

 

 

  1. Do you know what is called little endian big endian problem? Can you give me one piece of code in which this problem will occur? For example printing the IP address in dot format (how we should write this program in a portable way)
  2. If we use malloc(0), do we get same behavior in all platforms? How to write portable code to prevent this kind of problems?   
  3.  

 

UNIX

 

  1. What is called address space of a process? Suppose a process is running, I want to see the address map of that process, how do I do that?
  2. Suppose I want to check how much memory one process is taking. How I should do that? What is the interpretation of RSS/SIZE column of ps/top command?

 

  1. Why generally we get SEGV/SIGBUS? Have you encountered SIGBUS ever? Explain me the scenario and how did you fix that particular bug?
  2. Can you check out this code and let me know whether I can get any SIGBUS from this code when I compile this code in sparc machine?

 

#include <stdlib.h>

 

int main()

{

   double *d; float *f;

   char *buffer_ptr = malloc(1024);

   f = (float*)  buffer_ptr;

   buffer_ptr += sizeof(*f);

   d = (double*) buffer_ptr;

   d[0] = 0.33;

   return 1;

}

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1.  

 


C Programming and Data structure

 

  1. What will be the output of the following C program

 

#include <stdlib.h>

void f(int I, int j)

{

    printf (“%d,%d”I,j);

}

 

main()

{

     int i=1;

     f(i++,i++);

}

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


  1. What is meant by pass by value and pass by reference? What will be the output of the following program?

 

 

#include <stdlib.h>

void f(char* p)

{

   p = (char*)malloc(100);

   Strcpy(p,”hello world”);

}

 

main()

{

   char* p=NULL;

   f(p);

   printf(“%s”,p);

}

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


  1. What will be the output of the following program?

#include <stdlib.h>

void f()

{

        printf(“%s”,(char *)((int *)(“hello world how are you”) + strlen(“hell”)) );

     }

 

 

main()

{

   char* p=NULL;

   f(p);

   printf(“%s”,p);

}

 

 
 

 

 

 

 

 

 

 

 


  1. Given an array t[100] which contains numbers between 1..99. Return the duplicated value. Try first O(n-sqare) and then O(n).
  2. How to find the loops in a linked list?
  3. How to reverse a linked list?
  4. How to find the number of 1s in a byte

 

Debugging/Tools

 

  1. What are the different debuggers you have worked with? What is meant by debug info? Where it can be stored? Do you know any special format of debug info?
  2. What are the ways of handling multiple process debugging? (fork exec etc)
  3. Have you ever worked with any performance improvement project? How to find out which functions are taking more time.
  4. What information you can tell when you have a core dump from a stripped executable and a debug version of the executable?
  5. What is the content of core file?
  6. When you are finding that the problem is in a function but the function is getting called several 100 times, how you will debug?
  7. When you use purify/valgrind? Tell me some errors which you fix through purify?
  8. purecov, what do you do with the .pcv file? How do you merge them into a single .pcv file.

 

Unix/scripting knowledge

 

  1. What is the use of “export” keyword in ksh
  2. When I run a shell script like “./a.sh” and “. a.sh” what is the basic difference
  3. I want to kill all instances of “netscape” process running. How I will do that?
  4. Do you know xargs command? What it does? If I ask you to implement the xargs command itself in C program/shell script how you will do that?
  5. I have several .c files in my home folder. I want to rename all of them to .C. How to do that?
  6. How to match an 24 hours clock in regex, like 21:59pm and 09:10am
  7.  

 

Integration related

  1. What is your responsibility in the SCM role. What are the main responsibilities of a release engineer?
  2. What kind of automation you did in your last SCM role.
  3. How introduction of different platforms complicate the release engineering activity. Do we need anything special for that?
  4. Why do we need branches?
  5. How do you merge different branches? In which case we can have a conflict. How to resolve merge conflict when there is a big of number of them.
  6. When there is a build failure what you do? What are the different reasons of build failure you have seen?
  7. How to find out which symbols are defined in a archive/.so file. How do you know it is defined/referenced/static etc.
  8. What are called symbols? Stack variable, global variable, defined functions, referenced functions, extern variables, static variables?
  9. Does the order of  “–l “ libraries matter in the link line
  10. I have two files .c files a.c and b.c. I want to create an executable (a.exe) from a.c and a library from b.c (libb.a). a.exe is depending on libb.a. Can you write a small Makefile for this purpose? If I want to compile a.c every time irrespective of change in timestamp what should I do?
  11.  

 

 

Puzzles

  1. I will give you the hour and the minute hand of a watch. You need to tell me the angle formed between them at that time, like at 12:00 the angle is 0 at 3:00 the angle is 90 etc.
  2. Given a rectangular cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife?
  3. There are 3 baskets, one of them has apples, one has oranges only and the other has mixture of apples and oranges. The labels on their baskets always lie. (i.e. if the label says oranges, you are sure that it doesn't have oranges only, it could be a mixture) The task is to pick one basket and pick only one fruit from it and then correctly label all the three baskets.
  4. You have 8 balls. One of them is defective and weighs less than others. You have a balance to measure balls against each other. In 2 weighing how do you find the defective one?
  5. You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

 

No comments: