Computer Science, asked by 1804224ece, 2 months ago

int find(int i) {
if(>1)
j=find(j/10)+(j%10)
else
j=0;
return j;
void main()
int i=1000
int k
k=find(i):
printf("%d", K)​

Answers

Answered by SwapnaChakraborty198
6

#includeint main()

{

   int x = 10, y = 20;

   if(!(!x) && x)

       printf("x = %d\n", x);

   elseprintf("y = %d\n", y);

   return0;

Correct answer - x = 10

Answered by pruthaasl
1

Answer:

The output of the given code is 0.

Functions:

  • A function is a subprogram or a subroutine, similar in form to a program.
  • It is declared in the declaration part of a program and is executed when its name is called.
  • A function definition consists of a name, parentheses containing parameters, and a body.
  • The function definition always consists of the function’s return value,  function name, function’s parameter list, and the actual function body, enclosed in curly braces
  • A function can be called any number of times in any part of the code with different parameters.

Recursive Functions:

  • A function that calls itself, again and again, is known as a recursive function.
  • How a recursive function is declared, defined, and called are all similar to a normal function.
  • Whenever a function is called, the value of the function must be assigned to the left-hand side of the variable.
  • Recursive call is faster and recursive function takes less memory space.

Explanation:

  • The given code consists of two parts, a function, and the main function.
  • The return value of the function find is an integer type and it has one argument.
  • On invoking, the function first checks whether the passed value is greater than one or not using the if statement.
  • If the value is greater than one, the function is called again by passing a value i/10
  • The value obtained is then added to the result of i%10 and assigned to a variable j.
  • If the value passed while calling the function is less than or equal to one, then the function assigns value zero to variable j.
  • The value assigned to variable j is then passed back to the calling statement.
  • The value returned from the find function is assigned to a variable k in the main function.
  • The value stored in k is then printed and the program is terminated.

Therefore, for the given program, the output value is zero.

#SPJ3

Similar questions