Thursday, February 28, 2013

What is the difference between a full outer join and a cross join?

For sets of A and B rows, a cross join (aka Cartesian join) fetches a result of A * B rows whereas a full outer join pulls a return of at most A + B rows.

How could you execute a shell script or command during system bootup (like startup in Microsoft Windows)?

Put that command or shell script (with actual path) inside the file "/etc/rc.local".

What is the last file that gets executed during system startup in UNIX?

It is "/etc/rc.local".

Wednesday, February 27, 2013

Explain the meaning of "Segmentation Violation".

At the time of compiling the program, a segmentation violation usually indicates an attempt to access memory which doesn't even exist.

What is the advantage of 'do-while' loop as compared to 'while' loop?

A while loop checks the condition first before executing the content whereas do-while loop executes the content of the loop before checking the condition and makes obligatory to enter the loop at least once.

What is the size of register for storage class?

register is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the size of a processor's general-purpose registers (GPRs) and the default size is usually one word or 2 byte or 16 bits.

What are Bit-fields?

The variables defined with a fixed width are called bit fields. A well-known usage of bit-fields is to represent a set of bits, and/or series of bits. They are space-saving structure members. They allow integer members to be stored into memory spaces smaller than the compiler would ordinarily allow. The default integer type for a bit field is unsigned.

The declaration of a bit-field inside a structure has the form:

struct
{
  type [member_name] : width ;
};

What is a self-referential structure?

A structure containing a reference to itself as a member is known as Self-Referential Structure.

struct linked_list_node
{
int data;
struct linked_list_node *next;  // self reference
};

What do you mean by associativity and precedence?

Precedence denotes the order or priority of evaluation whereas associativity implies the direction of evaluation.

What are dangling, wild, void, and null pointers?


A pointer pointing to a memory location which is deleted or freed is known as Dangling Pointer.

A pointer which has not necessarily initialized prior to its usage is a Wild Pointer.

A pointer pointing to nothing or that does not refer to a valid memory location is a NULL Pointer.

The pointer not having any type associated with it and can hold the address of any type is known as Void Pointer (aka Generic Pointer).

Are functions declared or defined in header files?

Traditionally the standard functions are declared in header files and defined in the library routines only.

What is the difference between '#include' and '#include "File"'?


It is compiler dependent. Generallly '#include "File"' prioritizes headers to be checked in the current working directory over system headers. And if there is not a suitable match, it moves on to check the system paths. "#include <File>" always looks out for system headers.

How could you find the size of a variable with out using sizeof operator?


#include <stdio.h>

#define SIZEOF(var)  ((size_t)(&(var)+1) - (size_t)(&(var)))

main( )
{
int x;
printf ("The size of x is %d\n", SIZEOF(x) );
}

Monday, February 25, 2013

How could you multiply 2 Integers using bit-wise operators?


#include<stdio.h>

main()
{
int a, b, num1, num2, result=0;  
printf("\nEnter the numbers to be multiplied :");
scanf("%d%d",&num1,&num2);
a=num1;
b=num2;
while(num2 != 0)            
{
if (num2 & 01)              
               {
        result+=num1;  
               }
num1<<=1;                
                num2>>=1;                
}
printf("\nMultiplication of %d*%d=%d", a, b, result);
}

What is the difference between '#define' and 'typedef'?


(a) typedef keep the property of attributes whereas #define doesn’t. For example

typedef char *type_t;
#define char *type_d

type_t s1,s2;
type_d s3,s4;

In the above declarations, s1,s2 and s3 are all declared as char* but s4 is declared as a char, which is probably not the intention.

(b) #define keeps string attributes whereas typedef doesn’t.

#define int INT;
typedef int MYINT

unsigned MYINT a;
unsigned INT a; /* Illegal */

For the typedef scenario, it doesn't change to unsigned 'int a' but in #define case it works!!!.