Cisco Systems Interview Question: Please write code to compute ... | Glassdoor

Interview Question

Intern Interview(Student Candidate) San Jose, CA

Please write code to compute x^x without using multiple

Answer

Interview Answer

5 Answers

0

Use two for loops

Interview Candidate on Feb 16, 2011
0

int mul(int x,int y){
int z=0;
while(y!=0){
if((y&1)==1)
z=z+x;
y=y>>1;
x=x<<1;
}
return z;
}

mvl on Aug 2, 2011
0

We can do this by taking the logarithm also

ynk on Apr 1, 2013
0

public double xToTheX(double x){
     return power(x, x);
}
private double power(double x, double y){
     if(y == 0) return x;
     if(y > 0) return x * power(x, y - 1);
     if(y < 0) return 1 / power(x, -1 * y);
}

Anonymous on Nov 25, 2014
0

#include
using namespace std;

int xxx(int x, int val)
{
    if(val > 0)
    {
        int result = 0;

         for(int k=0;k> x;
    // your code goes here
    int answer = xxx(x,x);
    cout << answer;
    return 0;
}

mnmp: code tested with ideone.com on Aug 30, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.