Showing posts with label Exact. Show all posts
Showing posts with label Exact. Show all posts

Wednesday, 23 February 2011

Address of a variable in c


Location in a memory where a variable stores its data or value is known as address of variable. To know address of any variable c has provided a special unary operator & which is known as deference operator or address operator. It operator is only used with variables not with the constant. For example:



#include

int main(){

    int a=5;

    printf("Address of variable a is: %d",&a)

Definition of variable in c


Definition of variable in C programming language:


A variable is named location of data. In other word we can variable is container of data.




    In real world you have used various type containers for specific purpose. For example you have used suitcase to store clothes, match box to store match sticks etc. In the same way variables of different data type is used to store different types

Identifier naming rule in c




In c any name is called identifier. This name can be variable name, function name, enum constant name, micro constant name, goto label name, any other data type name like structure, union, enum names or typedef name.




Rule 1:  Name of identifier includes alphabets, digit   and underscore.







Valid name: world, addition23, sum_of_number etc.






Invalid name: factorial#, avg value,

Value of variable in c language



Explanation of value of a variable in c programming language
by examples and questions and answers


Data which any variable keeps is known as value of variable. For example:



int a=5;



Here value of
variable a is five. Name of variable always returns value of the variable.



How to assign
any value to a variable:



C supports
eleven type of assignment operator to assign any value to

Declaration of a variable in c



Declaration of variables in c:



Declaration of
variables means to acknowledge the compiler only about variable name and its
data type with its modifiers but compiler doesn’t reserve any memory for the
variables.



In c we can
declared any variable with help of extern keyword while it has not initialized. Example of declaration:



(1) extern int a;



(2)extern struct student{

    char *

Sunday, 3 February 2008

System Level programming by c program



Important structure and union:




The header file dos.h defines two important structures and one union. They are:

1. struct BYTEREGS {

unsigned char al, ah, bl, bh;

unsigned char cl, ch, dl, dh;

   };



2. struct WORDREGS {

unsigned int ax, bx, cx, dx;

unsigned int si, di, cflag, flags;

   };



3. union REGS {

struct WORDREGS x;

struct BYTEREGS h;

  };




Note: Try to remember