main(){ printf(“%x”,-1
extern, static variables, enum, register
Static variable When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can beContinue reading… extern, static variables, enum, register
Computer Organization
IR
Complete binary tree and Full binary tree
Full and Complete binary trees are different. All full binary trees are complete binary trees but not vice versa. Full binary tree needs 2^n-1 nodes
Heterogenious linked list
If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It isContinue reading… Heterogenious linked list
Sort linked list
Node *MoveMinToStart(Node *aHead) { if(aHead == NULL or aHead->next == NULL) return aHead; Node *PrevMin = NULL,*Cur=aHead,*Prev=NULL,*Min=NULL; while(Cur){ if(Min == NULL or Min->Value > Cur->Value){ Min = Cur; PrevMin = Prev; } Prev = Cur; Cur = Cur->next; } if(PrevMinContinue reading… Sort linked list
Redefining inbuilt data types
#include typedef int INTEGER /* will work */ But #define INTEGER int /* will also work*/ INTEGER SomeFunction() { …… code return 0; } This will work But Rule of thumb is #defines are used for textual replacement whereas typedefsContinue reading… Redefining inbuilt data types
Repeating characters
Write a funtion that finds repeating characters in a string. Sort the string
Draw circle, using integer operations
Q: Write a routine to draw a circle given a center coordiante (x,y) and a radius (r) without making use of any floating point computations. Refer to graphics algorithms
Give a fast way to multiply a number by 7
Represent 7 in binary format. Now shifting and adding by appropriate times will give the solution or Multiply it by 8 (shift by 3 bits) and subtract the original number.