NVIDIA Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
5
of 5 vote

#include <stdio.h>
		int main(){
		    
		   unsigned int i = 1;
		   char *c = (char*)&i;
		   if (*c)   
		       printf("Little endian\n");
		   else
		       printf("Big endian\n");
		   getchar();
		   return 0;
		}

- pradegup October 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 vote

int a = 0xabcdef;
char *c = (char *)&a;
if (*c == a)
printf ("Big Endian");
else
printf ("Little Endian");

- Vikas June 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you please explain how it works?

- manishvaidya June 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Dump the bit representation for an int set as 1 in GDB. If big endian, the 1 will be on the right end, whereas if it is little endian, the 1 will be on the left one. Most computers today (x86/x86-64 architecture) are little endian.

- JYChen October 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

take an integer assign 1 to it.
take a character pointer and assign it to the address of the int check first and last value

int a = 1;
char *c = (char*)&a;
if (*c == 1)
----
else if (*(c+3) == 1)
-----

else

error

- soumyajuit May 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about setting the value of a character as 1 and then right shifting the variable. Endian ness can be found out by OR ing the value with 0.

- rahulbmv October 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

enum { BigEndian, LittleEndian };

int endianness(void)
{
union
{
int i;
char b[sizeof(int)];
} u;
u.i = 0x01020304;
return (u.b[0] == 0x01) ? BigEndian : LittleEndian;
}

- Anand Madhab October 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote
{{{const int i=1; if (*(char*)i == 0) { //big-endian : 32 bits stored as B0B1B2B3. So you are interpreting B31 as the char. } else {//should be 1 //little endian : 32 bits stored as B31B30...B1B0. char ptr points to B0. } - bleh October 25, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More