Honeywell interview experience


  • on-campus,  No CGPA cut-off
  • First Round: Written test comprising the questions from core subjects(I am from telecommunication systems engg)
  • Second Round : Technical Personal Interview
    • everything about C
    • what is static, #define, typedef and difference between the last two
    • macro function
    • pointers to constants and constant pointers difference with example codes
    • postfix and prefix with live example
    • stack push operation, explanation and syntax for data structure used for the stack
    • why don't you learn machine learning, oops, IoT?
    • what differentiates you from a student from normal colleges(I am from IIT)
    • why honeywell?
    • Where do you want to see yourself in two years
  • Finally I was expecting HR round but there was no such for me. In the final selected list my name was in wait list.
  • My observations:
    • Their time-management for interview was bad and hence there was no time for them to conduct HR round for some of us(I am one among such).
    • They give lots of importance to those who used C programming for their academic project.
 If you have something, feel free to ask. I hope it helps some people.

Brute Force method to operate on every possible set of an array

Problem Statement: Given an array, operate (possibly sum/product) on every possible non-empty subset.
Its helpful in so many contexts if you have no idea to solve the problem optimally. It runs in exponential time.

Given n, m. There are m elements in the array. You have to find the number of ways in which given sum = n can be obtained  using non-empty subsets of the array.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

long long coinChange(int cost[], int m, int n){
    char binary[m];
    memset(binary, 0, sizeof(binary));
    long long x = (long long)pow(2, m) ;
    long long i, ans = 0;
    for (i = 1; i < x; i++){
        int j = m-1;
        while (binary[j] != 0 && j >= 0){
            binary[j] = 0;
            j--;
        }
        binary[j] = 1;
        int k;
        long long sum = 0;
        for (k = 0; k < m; k++){
            if (binary[k] == 1)
                sum += cost[k];
        }
        if (sum == n)
            ans++;
     
    }
    return ans;
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int cost[m];
    int i;
    for (i = 0; i < m; i++)
        scanf("%d", &cost[i]);
    printf("%lld", coinChange(cost, m, n));
    return 0;
}

How to read mix of integers and characters from input?

To Better understand the essence of this program try the below quiz program before proceeding

To begin with, you must understand how scanf and keyboard buffers work when try to read the input.

when you read an integer with a statement like

scanf("%d", integer); // integer is of int type.
you will type integer(say 6) followed by enter key.
The keyboard buffer strores 6 and "new line"('\n').
the first scanf statement takes one integer from the keyboard buffer and as a result the new line character remains in keyboard buffer.
the next scanf statement takes this character.
scanf("%c", character) // character is of char type
So that the character variable takes that newline character into it.

Our intended function of those two scanf statements is to read one integer followed by some code to process that data, followed by a character input as in following program;

#include <stdio.h>
int main()
{
      int a, b, c;
      printf("\nenter a: ");
      scanf("%d", &a);
      printf("enter b: ");
      scanf("%d", &b);
      c = a+ b;
      char ch;
      printf("enter character") ;
      scanf("%c", &ch);
      printf("\nthe entered character is: %c", ch);
      return 0;
}

As pointed out earlier, the problem was due to the storage of new line character in the keyboard buffer.
So add a statement while((ch = getchar()) != '\n'); inbetween the statements for reading integer and reading character. This statement takes the newline in the buffer into it. So the scanf statement for charcter input behaves as expected.

The modified code is the following:
#include <stdio.h>
int main()
{
      int a, b, c;
      printf("\nenter a: ");
      scanf("%d", &a);
      printf("enter b: ");
      scanf("%d", &b);
      c = a+ b;
      char ch;
      printf("enter character: ") ;
      while((ch = getchar()) != '\n');
      scanf("%c", &ch);
      printf("the entered character is: %c", ch);
      return 0;
}

Note: There are some alternatives for the same purpose, if you are interested, discuss in comments section.

Quiz 8

This is sensible question. You may not understand the purpose of this question until you compile and run. However, I strongly recommend you to trace the output for your input and check your result with original result by running it in your computer.


#include <stdio.h>
int main()
{
      int a, b, c;
      printf("\nenter a: ");
      scanf("%d", &a);
      printf("enter b: ");
      scanf("%d", &b);
      c = a+ b;
      char ch;
      printf("enter character") ;
      scanf("%c", &ch);
      printf("\nthe entered character is: %c", ch);
      return 0;
}

Explanation: how to read mix of integers and characters

how to upgrade to windows 10 from windows 8.1

If you want to upgrade to windows 10 from windows 8.1 then follow* this procedure.

step1 : make sure you have installed all updates from windows. This is done as follows.
           control panel > search for update in control panel search box > click on windows update > check for updates > if there are any updates, install them. once again make sure, you have installed all updates asa same as above.

step2 : download file from
step 3: run the file
step 4 : click on upgrade this pc.
now the download should start. 
if you got error like "something happened", then do the following
 open control panel > search for region > click on region > click on administrative > chane local> put english(united states) in that and click ok
now run that downloaded file again.
your download should start now.
be patient ... you need to do nothing until it gets downloaded 100%
then some processes start by themselves.
be patient..
in the entire process, it asks your permission thrice only.
You got windows 10 on your PC.
All the best.

If you have some issue/solution, Feel free to share here.

*this is for information only. There is no guarantee that it will work for u.

Simple calculator

Problem Statement: Execute simple arithmetic operations sum, subtract, multiplication, division on integers.

How its different from others on internet :  There are so many websites which have code for simple calculator program. However most of them, asks for two integers first and then asks for operator which is not the case in real time calculator. In this code, you can directly enter expressions like        76 * 75, which is similar to real time calculator.

Input : operand1 operator operand2
Output : result of the input arithmetic expression.

Code:

#include <stdio.h>
#include <string.h>

float calculate(int op1, char op, int op2, unsigned short * flagptr); // calculator function
int main()
{
 char oparr1[10], oparr2[10];
 char op;
 float result;
 unsigned short flag = 1;   // flag which indicates any error in input
 unsigned short *flagptr = &flag; // pointer to the above flag
 printf("enter expression operand1 operator operand2\n");
 int ch;
 ch = getchar();  // start reading input
 int i= 0;
 while(ch >= '0' && ch <= '9')   //store in array of operand1 if its number
 {
    oparr1[i] = ch;
    ch = getchar();
    i++;
 }
 while(ch == ' ')       // skip all the spaces between first operand and operator, if any
 {
    ch = getchar();
 }
 op = ch;      // store operator in op
 ch = getchar(); 
 while(ch == ' ')
 {
    ch = getchar();
 }
 i= 0;
 while(ch >= '0' && ch <= '9')      //start reading operand2
 {
    oparr2[i] = ch;
    ch = getchar();
    i++;
 }
 int op1, op2;
 op1 = atoi(oparr1);     // convert char array of operand1 to integer
 op2 = atoi(oparr2);
 result = calculate(op1, op, op2, flagptr);
 if (flag == 1)              // no error in input
    printf("result = %f\n", result);
 else
    printf("undefined result\n");
 return 0;
}

float calculate(int op1, char op, int op2, unsigned short *flagptr)
{
    float result;
    switch(op)
    {
        case '+': result = op1 + op2;
                break;
        case '-': result = op1 - op2;
                break;
        case '*': result = op1 * op2;
                break;
        case '/':
                if (op2 != 0)
                    result = (float)op1/op2;
                else
                    {
                       printf("divide by zero error\n");
                       *flagptr = 0;   // indicate error in input
                    }

                break;
        default : printf("Use integers only\nUse +, -, * and / only\n");
                     *flagptr = 0;
                      break;

    }
    return result;
}
 



Sample input: 25 * 25
Output : 625.00000

What can be improved? 
Ans: Well, this program works only for integers. Try for floating point values and use it as your own calculator. Discuss in comments, how to implement it for float values.