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
#include<stdio.h>
#include<unistd.h>
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));
}
What is the time complexity of this code?
ReplyDeleteKindly tell me. Thanks
Its time complexity is constant i.e. O(1)
DeleteKindly tell me whats the loop invariant
ReplyDeletehttp://lmgtfy.com/?q=loop+invariant
Delete