Posts

Showing posts from June, 2015

Confusing Pointer Operations : *++ptr, ++*ptr, *ptr++ ( c Interview question - 1)

Important Points: 1. Postfix operation has more precedence than dereference operator.         *p++ means it will be *(p++).. * will be applied to the result of p++. 2. Prefix Operation has the same precedence with the dereference operator.When there is same precedence we have to take associativity into picture, The associativity is right-left . In ++*ptr , first it will dereference and then increment , whereas in *++ptr it will increment the value and dereference. To easily understand this we will take an example of a C program. #include <stdio.h> int main() {        char ptr[]="Hello World";        printf("Value :%s\n", ptr);        ++*ptr;        printf("Value :%s\n", ptr);        return 0; } In the above example you can see that we are having prefix operator and dereference operator.We know that both are having the same precedence, then we will look at the associativity which is  right to left so first it gets dereferenced and

C Program to read the serial data from arduino

#include <stdio.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <termios.h> int main(int argc, char *argv[]) { int fd; char buff[100]; struct termios options; fd = open("/dev/ttyACM0", O_RDWR|O_NOCTTY|O_NDELAY); if (fd == -1) { perror("Error Opening File\n"); return -1; } printf("File Opened Successfully\n"); /* Check if the file descriptor is pointing to a TTY device or not */ if (!isatty(fd)){perror("Not a tty\n");} /* Get the current configuration of the serial interface */ tcgetattr(fd, &options); cfsetispeed(&options, B9600); cfsetospeed(&options, B9600); options.c_cflag &= ~PARENB; /*No Parity*/ options.c_cflag &= ~CSTOPB; /* 1 Stop Bit */ options.c_cflag &= ~CSIZE; options.c_cflag |= CS8 ; /*8 Bits*/ options.c_cflag &= ~CRTSCTS; /*no hardware flow control*/

Tata Elixsi Interview Experience

1. Tell me about yourself 2. Questions about project 3. Write a C program to check whether a particular character exists in a string?also testcases to be written 4. Write a code to check the endianess of the microcontroller 5. Write a macro to find the square of a number 6. What is ISR and how interrupt latency is reduced

Mirafra Technologies Interview Experience

1.Tell me about yourself 2.Rate yourself in C on a factor of 1 3.What is void pointer 4.volatile keyword in C 5.Storage classes in C 6.Static keyword in C 7.const keyword in C 8.Which DeviceDrivers u have worked on 9.Explain about I2C.Start and stop condition 10.Synchronization Mechanisms 11.Difference between semaphore and mutex 12.use of spinlock 13.What is system call and what happens internally 14.Between ISR and process which we wil use semaphore or spinlock 15.Interrupt Mechanism in linux 16.Top Half and Bottom Half 17.WorkQueues 18.What are the Debugging mechanisms used ?

Honeywell Interview Experience

1. Tell Me Yourself? 2. Explain about your project? 3. Why you have choosen MSP430F series? What is the speciality about MSP430F series? 4. Write steps to configure an ADC? Use any microcontroller? Is timer required for ADC? 5.Tell some of the interrupts? 6.Process of creating a socket?Is the file created in the file system will have an address(Major and Minor Number) 7.What is the structure used for filling IP Address and Port(struct sockaddr) 8.TCP Header size.What are the fields present in the TCP header. 9.Read System Call. 10.Synchronization Mechanisms. 11.What is a semaphore(API's)? How many types of semaphore are there? 12.What is the difference between semaphore and mutex? 13.What is context switch?How internally the operations happens? 14.How an interrupt is requested in Linux ?request-irq()?What are the arguments? 15.What is the necessaryof probe and init?Why can't we have only probe? 16.Do you know USB drivers? 17.Do you know multithreading? 18.