Wednesday, 3 February 2016

Byte Ordering | Bytes In order (Computer Networks)

Byte Ordering | Bytes In order (Computer Networks)

Description:    The following C program to find out the host byte ordering of a machine/computer.
C has a datatype short. It takes 2 bytes. We can store some data in short datatype and read memory byte wise

C Code


int main(){

   short a=500;
   unsigned char* p = (char *)&a;
   printf("\nActual Value: %i\n",a);
   printf("\nAt First Byte: %i\n",*(p+0));
   printf("At Second Byte: %i\n\n",*(p+1));


  1. What is the time complexity of this code?
    Kindly tell me. Thanks

  2. Kindly tell me whats the loop invariant


Recent Posts