Write a small C program to determine whether a machine's
type is little-endian or big-endian.

Answer Posted / vasundhara

int main()
{
int x=1;

if(*(char*)&x)
printf("little endian");
else
printf("big endian");

return 0;
}

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the time and space complexities of merge sort and when is it preferred over quick sort?

869


What are pragmas and what are they good for?

746


What is modeling?

815


Should I learn data structures in c or python?

750


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2884


What is "Hungarian Notation"?

836


What is #include called?

791


What is the use of function in c?

914


What is non linear data structure in c?

766


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

2078


Describe the steps to insert data into a singly linked list.

818


What does the function toupper() do?

864


Are there constructors in c?

763


write a program to copy the string using switch case?

2607


When should volatile modifier be used?

739