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
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 |
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 |
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 |
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
what is the function of .h in #include<stdio.h> in c ?
23 Answers HCL, IBM, Wipro,
why do some people write if(0 == x) instead of if(x == 0)?
What is use of pointer?
Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not
What is exit() function?
What is #error and use of it?
Where static variables are stored in c?
Write a program to compute the following 1!+2!+...n!
where does malloc() function get the memory?
C program to perform stack operation using singly linked list
What are the languages are portable and platform independent?Why they are like that?