Interview Questions

These are some of the most important questions that can be handy for the freshers who are looking for their career as a software developer.

5 comments:

  1. This is one of the most common interview question.

    Given an array of integers (positive and negative) find the largest continuous sum.

    If the array is all positive, then the result is simply the sum of all numbers. The negative numbers in the array slightly complicate things. The algorithm is, we start summing up the numbers and store in a current sum variable. After adding each element, we check whether the current sum is larger than maximum sum encountered so far. If it is, we update the maximum sum. As long as the current sum is positive, we keep adding the numbers. When the current sum becomes negative, we start with a new current sum. Because a negative current sum will only decrease the sum of a future sequence. Note that we don’t reset the current sum to 0 because the array can contain all negative integers.

    ReplyDelete
  2. Given an integer array, output all pairs that sum up to a specific value k. Write a program for this.

    ReplyDelete
  3. What is the output of this program?

    int main()
    {
    int a;
    a = 3;
    fun(a);
    printf("\n");
    return 0;
    }
    void fun(int n)
    {
    if(n > 0)
    {
    fun(--n);
    printf("%d",n);
    fun(--n);
    }
    }

    ReplyDelete
  4. Int main()
    {
    int x = 032;
    printf("%d", x);
    return 0;
    }

    what should be the output??

    ReplyDelete
  5. Assume that the size of an integer is 4 bytes. Predict the output?
    #include
    int fun()
    {
    puts(" Hello ");
    return 10;
    }
    int main()
    {
    printf("%d", sizeof(fun()));
    return 0;
    }

    ReplyDelete