int fun(int a,int b ){ if( !b ) return 1 int ans= fun(a,b/2) ans=ans*ans if( b%2 ) ans=(ans * a) return ans}What is output for fun ( 2,10 )?
Question
Solution 1
The function fun
is a recursive function that calculates the power of a number. It takes two arguments a
and b
where a
is the base and b
is the exponent.
Here's how it works:
- If
b
is 0, it returns 1 because any number raised to the power of 0 is 1. - It recursively calls itself wi Knowee AI is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI
Similar Questions
Predict the output for the given code for func(8, 2) ?int func(int a, int b){ int c; c = a << b; return c;}Select one:a. 16b. 8c. 4d. 32
What is the output of the following code?#include <stdio.h>int main() { int arr[5] = {1, 2, 3, 4, 5}; printf("%d\n", arr[3]); return 0;}
What will the following code output?#include <stdio.h>int main() { int arr[3] = {1, 2, 3}; int *p = arr; printf("%d\n", *(p + 2)); return 0;}
What is the output of the following code?#include <stdio.h>int main() { int arr[2][2] = {{1, 2}, {3, 4}}; printf("%d\n", arr[0][2]); return 0;}
find the output of given code.#include <stdio.h>int main(){int a,b=110,c=20;printf("%d",a=b-=c*=5);return 0;}-1045010110
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.