Posts

Showing posts from September, 2020

Why C is the most powerful language

  Modularity and less keyword unlike other languages that have dedicated keyword for simple math functions,   it has libraries more instead of keywords   that makes it   efficient . Complex Declarations   , using complex declaration you can define any real world entity Storage classes such as extern & register, inline, volatile, const keyword which are low level in nature etc. Direct   mapping of constructs to memory segments Pointers with   Pointer typecasting & treating Function name as pointer ,   i think pointers are useless without pointer typecasting. Function name is treated as pointer in C which makes it very powerful and also pointer arithmetic. Wide varieties of types   from long long to char , floating type such as float or double but has   weak type checking. void * / int * as a generic data storage Use of   expression   in every place whether it’s in   for , while or if for(expression ; expression; e...

Firmware Interview Questions

 He asked a puzzle that you have 500 switches and all are OFF. Now someone came and make all of them ON. Now a second person came and flip all the second switch and then 3rd came and flip all the 3rd switch and so on till 500. So tell me how many switch will be on after completing the entire process. synchronization mechanisms for threads associating a mutex with a condition variable solved it mutex reursive binary semaphore and mutex Clone a linked list into two different linked lists such that one list contains the first half of the existing linked list, in the same order, and the other list contains the other half. Time complexity should be minimum. How would you represent a sparse matrix using minimum space complexity such that all elements can be accessed through their row and column indices? Prepare a STAR matrix parse matrix. C programming to the depth. like triple pointers, linked lists, algorithms etc. 1st F2F was on checking the logical ability and problem solving along w...

Basic Parsing using strtok

  C string.h library provides functionalities for parsing like strtok() string tokenizer is a functionality which will tokenize the string using the delimiter It basically replaces the delimiter string(char *) with '\0' next time we do strtok we give NULL as input instead of char* token with delimiter string.  char *strtok(char *token, char* delimiter);  Usage of strtok in Computer Networks for IP Address Parsing #include <string.h> #include <stdio.h> #include <stdlib.h> int main() {   int val;   char c[64]="192.168.0.0";  // be careful it should be character array not character pointer   char *tok;   tok=strtok(c,".");   while(tok != NULL)   {      val = atoi(tok);      printf("%s %d %x %o\n",tok,val,val,val);      tok=strtok(NULL,".");   } }   Wide application of strtok can be used for questions like:- " I LOVE MY COUNTRY " " COUNTRY MY LOVE I" ...