Friday, April 19, 2013

memory allocation for 2D array

the memory of a computer is linear and not a matrix like a 2D array. So, the elements of the array are stored either by row, called "row-major", or by column, called "column-major". Row-major order is used most notably in C and C++ during static declaration of arrays.
In C, since the length of each row is always known, the memory can be filled row one row at a time, one after the other.
Example:
a[i][j] =
1 2 3 4 5 6 7 8 9
Representation in the memory: In row-major: 1 2 3 4 5 6 7 8 9 In column-major: 1 4 7 2 5 8 3 6 9
Address calculation of an element:

Row-Major :
addr (i,j) = B + W * ( Nc * (i - Lr) + (j-Lc) )

Monday, March 25, 2013

Array in c prograqmmming




There are times while writing C code, you may want to store multiple items of same type as contiguous bytes in memory so that searching and sorting of items becomes easy. For example:
  1. Storing a string that contains series of characters. Like storing a name in memory.
  2. Storing multiple strings. Like storing multiple names.
C programming language provides the concept of arrays to help you with these scenarios.

Saturday, March 23, 2013

Function in C Programming



                                           function



A  function is an independent
section of program code that performs a certain task and has been assigned a name.

 By  referencing a function’s name, your program can execute the code in the function.

Tuesday, March 19, 2013

Volt-Ampere Characteristics of pn Junction




Volt-ampere or V-I characteristic of a  pn  junction (also called a  crystal or semiconductor diode) is the
curve between voltage across the junction and the circuit current.  Usually, voltage is taken along  x-
axis and current along  y-axis. The below  fig.1  shows the  circuit arrangement for determining the  V-I
characteristics of a  pn  junction. The characteristics can be studied under three heads, namely;    zero     external voltage ,   forward bias and   reverse bias .

                                             Figure:1