-->

Sunday, December 21, 2014

How many error occurs in C language ?

There are three types of errors that may occur while developing or writing C program. There errors are:

1.Syntax Errors
2.Logical Errors
3. Runtime Errors

Syntax Errors:-
The set of rules (grammatical rules) of a programming language for writing statements of the computer program is known as syntax of the language. The program statements are written strictly according to these rules.

Syntax error occur when syntax of a programming language are not followed in writing the source code. The compiler detects these errors at compiling time of source code. The compiler reports a proper error message about the error.

Sunday, December 14, 2014

Why Programmer/Developer need to know about dangiling pointer and memory leak?


Answer:

Pointer helps to create user defined scope to a variable, which is called Dynamic variable. Dynamic Variable can be single variable or group of variable of same type (array) or group of variable of different types (struct). Default local variable scope starts when control enters into a function and ends when control comes out of that function. Default global vairable scope starts at program execution and ends once program finishes.

But scope of a dynamic variable which holds by a pointer can start and end at any point in a program execution, which has to be decided by a programmer. Dangling and memory leak comes into picture only if a programmer doesnt handle the end of scope.



Sunday, November 30, 2014

What is little endian and big endian or What is Network byte order and host byte order ?




               Little endian and Big endian are memory architecture to store Multi byte data into memory.Say integer,float data types are occupy more then 1 byte in memory.And these are also called as Network Byte order and Host byte order.

Little endian?

      Little endian means lower order byte in number is stored lower order address in memory.
 

       For example:

                     int number = 0x1234;
                  
                     Memory Address              Value                       
                        1000                                    34           ------>   Base_Addr_0 +  Lower_order_byte;
                        1002                                    12           ------>  Base_Addr_1  +  Higher_order_byte;


Big endian?


     Big endian means higher order byte in number is stored lower order address in memory..

For example:


                   int number = 0x1234;

                     Memory Address              Value
                      
                       1000                                    12             ---->   Base_Addr_0 +  Higher_order_byte;
                       1002                                    34            ----->  Base_Addr_1  +  Lower_order_byte;
 

The above example shows memory representation of integer data type which is stored Little and Big endian machines.

How to check your PC is based on little endian or big endian Architecture?

 Here, some example given below:-

      Example 1:

             
void main(void)
                  {
                           int number = 0x1234;   // 0x represent as Hex value
                           char *ptr=(char*) & number;  
                           if(*c==0x34)
                                   {printf("Little Endian");}

                           else if(*c==0x12)
                                    {printf("Big Endian");}
                            else { printf("**************");}

                   }
     Example 2:

             
void main(void)
                      {
                             int number =1;
                             if(*(char)&number==1)printf("Little Endian");                         
                            else printf("Big Endian");
                      }
                    
    Example 3: 

              
void show_memory(unsigned char*,unsigned char);  //Function declaration.
               void main(void)

                      {
                              int number= 0x1234;
                              char *ptr =(*char)&number;
                              show_memory(*ptr,sizeof(number)); //Function Calling
                              getch(); 
                              return 0;
                       } 

                        
               void show_memory(unsigned char *p,unsigned char n)

                      {
                                for(char i=0;i<n;i++) printf("%d  ",p[i]);                      }
                      

      Note : if your machine is little endian output will be 34 12....Suppose big endian means output will be 12  34


What bi endian? 

    Bi Endian means combination of little and big endian.Bi Endian processor can run in both little and big endian.

      Example of Little and big and Bi endian architecture?
  1. Intel based processors are Little Endian.
  2. ARM based processors were Little Endian...now its became Bi-Endian.
  3. MOTOROLA processors were Big Endian...now its became Bi-Endian.


  

Friday, November 7, 2014


 Disk Storage

   1 Bit = Binary Digit
  8 Bits = 1 Byte
1024 Bytes = 1 Kilobyte
1024 Kilobytes = 1 Megabyte
1024 Megabytes = 1 Gigabyte
1024 Gigabytes = 1 Terabyte
1024 Terabytes = 1 Petabyte
 1024 Petabytes = 1 Exabyte
1024 Exabytes = 1 Zettabyte
1024 Zettabytes = 1 Yottabyte
1024 Yottabytes = 1 Brontobyte
1024 Brontobytes = 1 Geopbyte

Receive Our Quality Tutorials Straight In Your Inbox By Submitting Your Email ID Below...

Your Information Will Never Be Shared.