Interview Question for Software Engineers


Country: India




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

bool isEven(int num) {
	    if (num & 1) {
	        return false;
	    }
	    else {
	        return true;
	    }
	}

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

bool isEven(int num) {
	    if (num & 1) {
	        return false;
	    }
	    else {
	        return true;
	    }
	}

- Pramod May 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool isEven(int num) {
	    if (num & 1) {
	        return false;
	    }
	    else {
	        return true;
	    }
	}

- pramod May 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool isEven(int num) {
if (num & 1) {
return false;
}
else {
return true;
}
}

- vinijasreevalsam May 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool isEven(int num)
{
int isOddOrEven = num & 1;
if(isOddOrEven == 1)
return false; // For Odd we return false
else
return true;// True for even
}

- Omprakash May 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool isEven(int num)

int isOddOrEven = num & 1;
     if ( isOddOrEven == 1)
           return false; // for odd it's false
     else
         return true;

- Omprakash May 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

function isEven(num) { 
     return num % 2 === 0;
   }

- Dinkleberg May 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

boolean isEven(int num){
return num % 2==0;
}

- Anonymous May 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Little modification in the question:-
Write a function which accepts an integer and prints if the the integer is even or odd.

Restrictions on your code:-
1. Code should not use any kind of condition checks(such as if..else, ?:[i.e. ternary operators],macros in any form).
2. Operators for checking equality like "==" should not be used.
3. Looping in any form should not be used.
4. No bitwise operators should be used.

- Adarsh May 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def f(val):
  print ("even", "odd")[val % 2]

- Simone May 30, 2016 | 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