Friday, June 18, 2010

Salary Negotiation and General Questions

IT Interview Question and Answer
This is the collection of Interview Question and Answers, I have collected form different source, I try to give answer of all questions, if you are not satisfied or you think answers are not correct you can post your comment for that, I also appreciate you if you submit interview question and answers for VB6, VB.Net, C#, ASP, COM, DCOM, COM+, ASP.Net, Crystal Report, Oracle, SQL Server, MySql, PHP, XML, AJAX. DBA.
If you are in information technology (IT) industry and working as a software engineer or developer, database administrator, you may need to give interview very often, as retration rate of our industry is very high, so be prepare for that. Interviewing of technical job position is very difficult as you have to demonstrate your "soft skill" in terms of your communication skills, personality and your "hard skill" means programming, analytical, implementation knowledge.
Tips for success in technical interview
·         Get enough information about the organization and product.
·         Practicing for technical question answer
·         Practicing for personal, general topics, other than technical question
·         Review the job description and profile.
·         Be on time
·         Follow Up, don't let them forget about you
·         Be ready for technical test and hands on exercise
·         Avoid arrogance
·         Dress and personality
·         Ask question, show interest for the post.
·         Try to control the flow of interview, remain composed.
·         Show confident, don't be confused
·         Don't use jargon and tech term if you don't know the things in details.
·         Don't try to misguide the interviewee as they are very experienced.
Salary Negotiation for IT job.
This is the probably the weakest area of for technical person. They are not from the sales and are not good in negotiators. Here is come tips for salary negotiations.
·         Do a study of what is the salary trend.
·         Do not mentioned your salary expected on the resume.
·         Do not be harsh during salary negotiations.
·         Talk with the employer in what frequency does the hike happen.
·         take care of hidden cost attached in salary clarify what exactly you will get.
Salary trend in IT industry in India and Abroad.

Years of Experience
Salary in India CTC
Salary in Abroad CTC
Freshers
INR 60 K to 100 K
$ 40 K to 50 K
1 to 2 Years
INR 120 K to 240 K
$ 50 K to 55 K
3 to 4 Years
INR 300 K to 360 K
$ 55 K to 60 K
5 to 6 Years
INR 360 K to 480 K
$ 60 K to 65 K
7 to 8 Years
INR 480 K to 720 K
$ 70 K to 80 K
8 Years and above
As per negotiations
As per negotiations

Non IT/Software/Database and HR Round related questions
You must ready and prepare for some non technical question in interview like.
·         Can you say something about yourself?
·         Why do you want to leave the current company?
·         where do you see yourself after three years?
·         What are your positive and negative points?
·         How much you rate yourself in .Net and C# in the range of 1 to 10 ?
·         Do you work on Saturday and Sunday?
·         Tell about your family background ?
·         How much time will you need to join our company ?
·         What is notice period for your current company ?
·         How you handle pressure situation ?
·         Why I should hire you ?
·         Do you work late nights ?
·         Do you like to work as a team or as individual ?

Thursday, June 10, 2010

Structure as Argument

Structure Arguments
There are many objects defined throughout the library as structures of
varying and possibly large sizes. Due to the inefficiency of passing structures
by value (copying the whole structure to a function), structures are generally
passed to functions by reference. Because of this, there is always a potential
to pass an invalid pointer to a function which expects a pointer to a structure.
The following examples illustrate the right and wrong ways to use such a
function. Given a structure and a library function which initializes it,
typedef  struct
{
    int   a, b, c, d;
} big_struct;

void    initialize( struct  big_struct   *s )
{
    s->a = 1;   s->b = 2;   s->c = 3;    s->d = 4;
}
the incorrect method of using this function is:

int  main()
{
    big_struct   *s;

    initialize( s );   /* WRONG */
}
because the variable s is
an uninitialized pointer. The correct method is to define a structure variable,
not a pointer to a structure, and pass a pointer to the structure:

int  main()
{
    big_struct   s;

    initialize( &s );
}
Alternately, the incorrect example above could have been corrected by allocating
the s pointer
before calling initialize.

Demo Project

#include<stdio.h>
#include<conio.h>
 struct student
 {
 int rlno;
 char na[20];
 }; //structure for student data

struct student stu; //global variable for structure

//Function to recieve value of structure

void getdata()
 {
 printf("\n Enter Roll Num ");
 scanf("%d",&stu.rlno);
 printf("\n Enter Name ");
 scanf("%s",stu.na);
 }
 //function to display values of structure

void showdata()
 {
 // printf("\n Name is %s ",stu.na);
 // printf("\n Roll Num is %d ",stu.rlno);
 printf("\n%d\t\t%s\n",stu.rlno,stu.na);
 }

 void main()
 {
 int ch; // var for choice
 int choice;
 int rl;
 FILE *fp, *fp1;//var to open a file
 while(choice!=5)
 {
 clrscr();
 printf("\n 1. Add data ");
 printf("\n 2. List Records ");
 printf("\n 3. Delete Record ");
 printf("\n 4. Modify Record ");
 printf("\n 5. Quit");
 printf("\n Enter your choice ");
 scanf("%d",&choice);
 switch(choice)
 {
 case 1:
 fp=fopen("stud.txt","a"); //openning a file
 while(ch!=0)//loop
 {
 getdata();//getting data
 fwrite(&stu,sizeof(stu),1,fp);//writing to a file
 printf("\n Press 1 to add more, 0 to quit ");//prompt the user for cont...
 scanf("%d",&ch);
 }
 fclose(fp);//closing a file
 break;
 case 2:
 fp=fopen("stud.txt","r"); //reopening a file
 printf("\n Roll Num\t\tName");
 printf("\n======================================\n");
 while(fread(&stu,sizeof(stu),1,fp)==1)//loop for reading data
 {
 showdata();//display a data
 }
 fclose(fp);//closing a file
 getch();
 break;
 case 3:
 fp=fopen("stud.txt","r");
 fp1=fopen("temp.txt","a");
 printf("\n Enter rollnum u wanna delete ");
 scanf("%d",&rl);
 while(fread(&stu,sizeof(stu),1,fp)==1)
 {
 if(stu.rlno==rl)
 {
 printf("\n Record found ");
 showdata();
 printf("\n Press any Key to cont...");
 getch();
 }
 else
 {
 fwrite(&stu,sizeof(stu),1,fp1);
 }
 }
 fclose(fp);
 fclose(fp1);
 remove("stud.txt");
 rename("temp.txt","stud.txt");
 break;
 case 4:
 fp=fopen("stud.txt","r");
 fp1=fopen("temp.txt","a");
 printf("\n Enter rollnum u wanna Modify ");
 scanf("%d",&rl);
 while(fread(&stu,sizeof(stu),1,fp)==1)
 {
 if(stu.rlno==rl)
 {
 printf("\n Record found ");
 showdata();
 printf("\n Press any Key to enter new Values");
 getch();
 getdata();
 fwrite(&stu,sizeof(stu),1,fp1);
 }
 else
 {
 fwrite(&stu,sizeof(stu),1,fp1);
 }
 }
 fclose(fp);
 fclose(fp1);
 remove("stud.txt");
 rename("temp.txt","stud.txt");
 break;
 case 5:
 printf("\n Thanks for using this software ");
 getch();
 break;
 default:
 printf("\n Invalid Option ");
 getch();
 }//switch
 }//while
 }

Monday, June 7, 2010

Multiply 2 Matrices

void main()
{
    int m1[10][10],i,j,k,m2[10][10],add[10][10],mult[10][10],r1,c1,r2,c2;
    printf("Enter 
number of rows and columns of first matrix MAX 10\n");
    scanf("%d%d",&r1,&c1);
    printf("Enter 
number of rows and columns of second matrix MAX 10\n");
    scanf("%d%d",&r2,&c2);
    if(r2==c1)
    {
        printf("Enter 
rows and columns of First matrix \n");
        printf("Row 
wise\n");
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c1;j++)
                scanf("%d",&m1[i][j]);
        }
        printf("You 
have entered the first matrix as follows:\n");
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c1;j++)
                printf("%d\t",m1[i][j]);
            printf("\n");
        }
        printf("Enter 
rows and columns of Second matrix \n");
        printf("Again 
row wise\n");
        for(i=0;i<r2;i++)
        {
            for(j=0;j<c2;j++)
                scanf("%d",&m2[i][j]);
        }
        printf("You 
have entered the second matrix as follows:\n");
        for(i=0;i<r2;i++)
        {
            for(j=0;j<c2;j++)
                printf("%d\t",m2[i][j]);
            printf("\n");
        }
        if(r1==r2&&c1==c2)
        {
            printf("Now 
we add both the above matrix \n");
            printf("The 
result of the addition is as follows;\n");
            for(i=0;i<r1;i++)
            {
                for(j=0;j<c1;j++)
                {
                    add[i][j]=m1[i][j]+m2[i][j];
                    printf("%d\t",add[i][j]);
                }
                printf("\n");
            }
        }
        else
        {
            printf("Addition 
cannot be done as rows or columns are not equal\n");
        }
        printf("Now 
we multiply both the above matrix \n");
        printf("The 
result of the multiplication is as follows:\n");
        /*a11xA11+a12xA21+a13xA31 
a11xA12+a12xA22+a13xA32 a11xA13+a12xA23+a13xA33*/
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c2;j++)
            {
                mult[i][j]=0;
                for(k=0;k<r1;k++)
                {
                    mult[i][j]+=m1[i][k]*m2[k][j];
                    /*mult[0][0]=m1[0][0]*m2[0][0]+m1[0][1]*m2[1][0]+m1[0][2]*m2[2][0];*/
                }
                printf("%d\t",mult[i][j]);
            }
            printf("\n");
        }
        getch();
    }
    else
    {
        printf("Matrix 
multiplication cannot be done");
    }
}


Binary Search



  1. int main() 
  2. {
  3.   int a[20] = {0};
  4.   int n,

  5. i, j, temp;   int *beg,

  6. *end, *mid, target;
      printf(" enter the total integers you want to enter (make it less then 20):\n");
  7.   scanf("%d", &n);
  8.   if (n >= 20) return 0;   //  ouch!
  9.   printf(" enter the integer array elements:\n" );
  10.   for(i = 0; i < n; i++)
  11.   {
  12.     scanf("%d", &a[i]);
  13.   }
  14. // sort the loaded array, a  must for binary search!
  15.   // you can apply qsort or  other algorithms here
  16.   for(i = 0;  i < n-1; i++)
  17.   { 
  18.     for(j = 0; j < n-i-1; j++)
  19.     {
  20.       if (a[j+1] < a[j])
  21.       {
  22.         temp = a[j];
  23.         a[j] = a[j+1];
  24.         a[j+1] = temp;
  25.       }
  26.  }
  27.  }
  28. printf(" the sorted numbers  are:");
  29.  for(i = 0; i < n; i++)
  30.   {
  31.  printf("%d ", a[i]);


  32.   }
      // point to beginning and end of the array

  33.   beg = &a[0];
      end = &a[n];  // use n = one element past the loaded array!
  34.   printf("\n beg points to address %d and end to %d",beg, end);  // test
  35.   // mid should point somewhere in the middle of these addresses
  36.   mid = beg += n/2;
  37.   printf("\n mid points to address %d", mid);  // test
  38.   printf("\n enter the number to be searched:");
  39.   scanf("%d",&target);
  40.   // binary search, there is an AND in the middle of while()!!!


  41.   while((beg <= end) && (*mid != target))
      {
  42.     // is the target in lower or upper half?
  43.   if (target < *mid)
  44.   {
  45.       end = mid - 1;     // new end
  46.   n = n/2;
  47.  mid = beg += n/2;  // new middle
  48.     }
  49.     else
  50.     {
  51.  beg = mid + 1;     // new beginning
  52.   n = n/2;
  53.   mid = beg += n/2;  // new middle     
  54. }
  55.   }
  56.  // did you find the target?


  57.   if (*mid == target)
      {
  58.  printf("\n %d found!", target);
  59.   }
  60.   else
  61.   {
  62. printf("\n %d not found!", target);
  63.  }
  64.   getchar();  // trap enter
  65.  getchar();  // wait
  66.   return 0;
  67. }

Saturday, June 5, 2010

C interview questions


C interview questions

  1. What does static variable mean?
  2. What is a pointer?
  3. What is a structure?
  4. What are the differences between structures and arrays?
  5. In header files whether functions are declared or defined?
  6. What are the differences between malloc() and calloc()?
  7. What are macros? What are the advantages and disadvantages?
  8. Difference between pass by reference and pass by value?
  9. What is static identifier?
  10. Where are the auto variables stored?
  11. Where does global, static, local, register variables, free memory and C Program instructions get stored?
  12. Difference between arrays and linked list?
  13. What are enumerations?
  14. Describe about storage allocation and scope of global, extern, static, local and register variables?
  15. What are register variables? What are the advantage of using register variables?
  16. What is the use of typedef?
  17. Can we specify variable field width in a scanf() format string? If possible how?
  18. Out of fgets() and gets() which function is safe to use and why?
  19. Difference between strdup and strcpy?
  20. What is recursion?
  21. Differentiate between a for loop and a while loop? What are it uses?
  22. What are the different storage classes in C?
  23. Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
  24. What is difference between Structure and Unions?
  25. What the advantages of using Unions?
  26. What are the advantages of using pointers in a program?
  27. What is the difference between Strings and Arrays?
  28. In a header file whether functions are declared or defined?
  29. What is a far pointer? where we use it?
  30. How will you declare an array of three function pointers where each function receives two ints and returns a float?
  31. What is a NULL Pointer? Whether it is same as an uninitialized pointer?
  32. What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
  33. What does the error ‘Null Pointer Assignment’ mean and what causes this error?
  34. What is near, far and huge pointers? How many bytes are occupied by them?
  35. How would you obtain segment and offset addresses from a far address of a memory location?
  36. Are the expressions arr and *arr same for an array of integers?
  37. Does mentioning the array name gives the base address in all the contexts?
  38. Explain one method to process an entire string as one unit?
  39. What is the similarity between a Structure, Union and enumeration?
  40. Can a Structure contain a Pointer to itself?
  41. How can we check whether the contents of two structure variables are same or not?
  42. How are Structure passing and returning implemented by the complier?
  43. How can we read/write Structures from/to data files?
  44. What is the difference between an enumeration and a set of pre-processor # defines?
  45. What do the ‘c’ and ‘v’ in argc and argv stand for?
  46. Are the variables argc and argv are local to main?
  47. What is the maximum combined length of command line arguments including the space between adjacent arguments?
  48. If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
  49. Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
  50. What are bit fields? What is the use of bit fields in a Structure declaration?
  51. To which numbering system can the binary number 1101100100111100 be easily converted to?
  52. Which bit wise operator is suitable for checking whether a particular bit is on or off?
  53. Which bit wise operator is suitable for turning off a particular bit in a number?
  54. Which bit wise operator is suitable for putting on a particular bit in a number?
  55. Which bit wise operator is suitable for checking whether a particular bit is on or off?
  56. Which one is equivalent to multiplying by 2?
    • Left shifting a number by 1
    • Left shifting an unsigned int or char by 1?
  57. Write a program to compare two strings without using the strcmp() function.
  58. Write a program to concatenate two strings.
  59. Write a program to interchange 2 variables without using the third one.
  60. Write programs for String Reversal. The same for Palindrome check.
  61. Write a program to find the Factorial of a number.
  62. Write a program to generate the Fibonacci Series?
  63. Write a program which employs Recursion?
  64. Write a program which uses command line arguments.
  65. Write a program which uses functions like strcmp(), strcpy(), etc.
  66. What are the advantages of using typedef in a program?
  67. How would you dynamically allocate a one-dimensional and two-dimensional array of integers?
  68. How can you increase the size of a dynamically allocated array?
  69. How can you increase the size of a statically allocated array?
  70. When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
  71. Which function should be used to free the memory allocated by calloc()?
  72. How much maximum can you allocate in a single call to malloc()?
  73. Can you dynamically allocate arrays in expanded memory?
  74. What is object file? How can you access object file?
  75. Which header file should you include if you are to develop a function which can accept variable number of arguments?
  76. Can you write a function similar to printf()?
  77. How can a called function determine the number of arguments that have been passed to it?
  78. Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
  79. How do you declare the following:
    • An array of three pointers to chars
    • An array of three char pointers
    • A pointer to array of three chars
    • A pointer to function which receives an int pointer and returns a float pointer
    • A pointer to a function which receives nothing and returns nothing
  80. What do the functions atoi(), itoa() and gcvt() do?
  81. Does there exist any other function which can be used to convert an integer or a float to a string?
  82. How would you use qsort() function to sort an array of structures?
  83. How would you use qsort() function to sort the name stored in an array of pointers to string?
  84. How would you use bsearch() function to search a name stored in array of pointers to string?
  85. How would you use the functions sin(), pow(), sqrt()?
  86. How would you use the functions memcpy(), memset(), memmove()?
  87. How would you use the functions fseek(), freed(), fwrite() and ftell()?
  88. How would you obtain the current time and difference between two times?
  89. How would you use the functions randomize() and random()?
  90. How would you implement a substr() function that extracts a sub string from a given string?
  91. What is the difference between the functions rand(), random(), srand() and randomize()?
  92. What is the difference between the functions memmove() and memcpy()?
  93. How do you print a string on the printer?
  94. Can you use the function fprintf() to display the output on the screen?
  95. What is a linklist and why do we use it when we have arrays? - I feel the correct answer should be linklist is used in cases where you don’t know the memory required to store a data structure and need to allocate is dynamically on demand.
  96. How do you detect a loop in linked list?
  97. What is the difference between main() in C and main() in C++?
  98. what will be printed out when the following code is executed:
    main()
    {
    printf("%x",-1<<4);
    }