Texas Instruments Interview Question for Software Engineer / Developers






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

If N is the input, N&15 will give you its mod 16.

Which company is asking these questions? Is it a phone interview? What position?

- CK August 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Here is the complete program:

#include <stdio.h>
int mod16(int);
void main()
{
	int no=33;
	printf("%d",mod16(no));
}
int mod16(int no)
{
	return no & (16-1);
}

- Kapil.smart1709 August 01, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can use fmod which returns the remainder of a division
eg.
fmod(N,16)

- Surya August 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use bit shift
int mod(int N)
{
return N-((N>>4)<<4);
}

- waterfall.zhang August 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

n & 0xf

- Anonymous August 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

None of the answers are correct :((

- aaa August 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sorry..i take by my comment :)

- aaa August 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

n&15

- Anonymous January 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just the jast 4 digits in the binary representation should be it.

- Nitish Gupta July 31, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int returnMod(int arg){
  arg|=0xF0;
  arg&=0x0F;
  return arg;
}

Basically what Nitish Gupta said, last 4 bits of the binary rep.

- Anon October 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

and

public int mod_16(int num){
		
		if(num < 16)
			return num;
		return mod_16(num-16);
		
	}


}

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

You can use same code as given in one of the answers but since * / - + isn't allowed,use >> and ^

int mod(int N)
{
return N^((N>>4)<<4);
}

- sschoudhary July 21, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main(){
	int num;
	cin>>num;
	cout<<(num&15)<<"\n";
	return 0;
	}

- Anonymous September 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main(){
	int num;
	cin>>num;
	cout<<(num & 15)<<"\n";
	return 0;
	}

- Kuldeep September 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

cout << N - (N/16)*16;

- Manish Sharma September 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A little hard but use the STL to convert the int to a bin number without arithmetic, then search for '1000'.

- yoyo March 08, 2015 | 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