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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / anuraag

Vasudhara's solution is correct!
Still here is an alternative solution to check endianess
without using pointers...

int main()
{
int x=0x58;
char ch;
ch=x;

if(ch=0x58)
printf("Little Endian");
else
printf("Big Endian");
return 0;
}

Is This Answer Correct ?    3 Yes 1 No

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

Answer / udita

little indian

Is This Answer Correct ?    5 Yes 8 No

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

Answer / sudheer

little india

Is This Answer Correct ?    2 Yes 8 No

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

Answer / mohana

The below code snipeet tells whether the system is little
or big endian.

int main()
{
int x=1;

if(x)
printf("big endian");
else
printf("little endian");

return 0;
}

Is This Answer Correct ?    7 Yes 24 No

Post New Answer

More C Interview Questions

What is huge pointer in c?

0 Answers  


What is meant by high-order and low-order bytes?

0 Answers  


Write a program to identify if a given binary tree is balanced or not.

0 Answers   JPMorgan Chase,


What is the c value paradox and how is it explained?

0 Answers  


What is memory leak in c?

0 Answers  






if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order?

4 Answers   Amazon, Apple, Bata, Google, NASA,


Which programming language is best for getting job 2020?

0 Answers  


Write a function to find the area of a triangle whose length of three sides is given

2 Answers  


Write the test cases for checking a variable having value in range -10.0 to +10.0?

0 Answers   Bosch,


Write a program to find the biggest number of three numbers in c?

0 Answers  


What is pass by reference in functions?

0 Answers  


write a program to find out number of on bits in a number?

17 Answers   Huawei, Microsoft,


Categories