Microsoft Interview Question for Software Engineer / Developers


Team: bing
Country: India
Interview Type: In-Person




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

In the current architectures int is 4 bytes long. signed int would be in the range -2^31 to 2^31.
unsigned int would be in the range 0 to 2^32.

- Anonymous March 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 votes

signed int should be -2^31 to 2^31-1. unsigned in should be in the range 0 to 2^32 -1

- Anonymous March 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I am posting very naive idea to get range of an integer..Hope it will work for all the architectures(16 Bit,32Bit,64Bit)..As we know integer uses 2s Complement..

#include <stdio.h>

int main()
{

register int i=1; // Using Register Storage Class In order to get faster result Still ,It is very Slow

while(1)
{
   if(++i<0) {
     printf("%d to %d",i,i-1 );
     break;
   }
}
return 0;
}

- User March 31, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ashish...can u tell us more about the written round..

- ann March 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

this type of question can only be asked in MS india..US guys will never ask this

- bodyguard December 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ann this question was asked during interview. and not writtten test...

- ashish March 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

int stored decimal no. of around
let A = sizeof(int) * 8;
then decimal no range is [-2^A to (2^A - 1)]

there must be a data structure in STL which allows storing decimal no of very very large range using the linked list kind of implementation.

- Bharat March 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

4294967295 max integer that an int can store.

- Anonymous April 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Declaring an int as register is just a request to the compiler not a command, This is the reason the program is still slow. I checked your program is working fine and fast on my machine. Try it on other machine.

- Nikhil April 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This might help.

#include<iostream>
#include<cstdlib>

using namespace std;

#define MY_SIZEOF(ele) ((unsigned char *)(&ele+1) - (unsigned char *)(&ele))

int main () {
	int a = 6;
	char b = 'c';
	size_t size;
	cout << MY_SIZEOF(a) << endl;
	cout << MY_SIZEOF(b) << endl;
	cout << MY_SIZEOF(size) << endl;
    return 0;
}

- Interested July 29, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Output

F:\New Desktop Folder\Repo\C++>g++ -std=c++11 My_SizeOf.cpp -o My_SizeOf.exe

F:\New Desktop Folder\Repo\C++>My_SizeOf.exe
4
1
8

- Interested July 29, 2014 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

int datatype range is : -32768 to +32767
2^range to 2^(range-1)
@ashish tell us more about your interview rounds.

- Anonymous March 26, 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