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

Explain what is the difference between far and near ?

0 Answers  


what are the facialities provided by you after the selection of the student.

0 Answers   TCS,


Describe static function with its usage?

0 Answers  


What are global variables?

0 Answers  


Are pointers really faster than arrays?

0 Answers  






what is the first address that gets stored in stack according to a C or C++ compiler???? or what will be the first address that gets stored when we write a C source code????????

2 Answers   Apple,


Explain how does flowchart help in writing a program?

0 Answers  


What are multidimensional arrays?

0 Answers  


What is a sequential access file?

0 Answers  


typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program?

1 Answers  


Input is "Jack and jill went up a hill" To print output is 1-letter word(s)-1 2-letter words-1 3-letter words-1 4-letter words-4

1 Answers   Mind Tree, TCS,


How would you rename a function in C?

0 Answers   Tech Mahindra,


Categories