Oracle Interview Question for Software Engineer / Developers






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

If we could use itoa(int n, int radix), we could convert it to base 3 and then drop the last letter of the string.
Then convert the string back to number (atoi()) and then convert the radix-3 back to radix 10 using standard procedures. (or please suggest a library function that does that if you know one).

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

Write your own DIVIDE using bitwise operators ... THAT IS ONE DUMB QUESTION or not a programming question but a logic design question!

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

<pre lang="c++" line="1" title="CodeMonkey2970" class="run-this">#include <stdio.h>

int main()
{
int n = 1000;
int a,b;
a = n >> 2;
b = (a >> 2);
a += b;
b = ((b+2)>>2);
a += b;
b = ((b+2)>>2);
a += b;
b = ((b+2)>>2);
a += b;
printf("a=%d\n", a);
return 0;
}


</pre><pre title="CodeMonkey2970" input="yes">
</pre>

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

You are using + operator here

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

int k = 15;
double value = log((double)k/3)/log((double)k);
int val2 = ceil(pow(k, value));//output = 2;

- AvCrash August 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry, output is 5)

- AvCrash August 11, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

bhai tu devide( / ) use kar rha h to...sidha sidha kyu nahi 3 se devide kar leta... :P

- dig July 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I have found a more elegant one:

int divideMe = 12;
int out = ((0xAAAAAAABULL * divideMe) >> 33);// out = 4;

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

Umm what about something like this:

num = log10(pow(pow(10,num),0.3333333333));

Obviously this doesnt work for large numbers. One can choose a smaller number to use as the base but there will still be limitations and (unless you use 'e') you will have to use division to divide by the log of that number.

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

try for n=9
it will give 2, but ans should be 3.

- coder September 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

God , please save me from these guys!
i think question clearly say not to use any arthimetic operations.

- Anonymous October 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good one , makes more sense than these other guys here!

- Riddle July 27, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

what about this code

void div(int n)
{
int i;
for(i=0;i<n;i++)
{
if(n>=3*i&&n<3*(i+1))
{   n=i;
printf("%d",n);
break;
}
}

i hope this works.. :)

- rohit.or.taneja August 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This can be achieved by 2 functions, one as the base addition, the other as the reverse of addition (i.e. subtraction) by multiple times.

public int add(int a, int b) {
        if (b == 0)
            return a;
        int sum = a ^ b;
        int carry = (a & b) << 1;
        return add(sum, carry);
    }

    //suppose a can be wholly divided by b
    public int division(int a, int b) {
        int i = 0;
        for (; a > 0; ) {
            a = add(a, -b);
            i = add (i,1);
        }
        return i;
    }

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

1).find the difference in sums of odd positioned bits and even positioned bits.
2).recursively check for this difference to be divisible by three.
3).base case of recursion : if(n==0||n==3)return true; if(n==1||n==2)return false;

- Nimish November 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Logic: division is nothing but successive subtraction. Now here is the logic
a+b can be coded as (a^b)|((a&b)<<1) now things are really simple if we want to achieve a-b we can say a+(-b). apply this recursively to achieve division. :-)

- Uttam March 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

<pre lang="" line="1" title="CodeMonkey36734" class="run-this">/* The class name doesn't have to be Main, as long as the class is not public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String s;
while (!(s=r.readLine()).startsWith("42")) System.out.println(s);
}
}

</pre><pre title="CodeMonkey36734" input="yes">1</pre>

- Anonymous July 06, 2011 | 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