Showing posts with label Recursion in C. Show all posts
Showing posts with label Recursion in C. Show all posts

Monday, September 26, 2022

Recursion in C

Find the output of the following recursive algorithm.

 #include<stdio.h>

  int counter = 0;

  int calc(int a, int b) {

  int c;

  counter++;

  if (b==3) {

  return (a*a*a);

          }

  else {

    c = calc(a, b/3);

    return (c*c*c);

 }

}

int main (){

  calc(4, 81);

  printf ("%d", counter);

  }


Output: 4

GRAPH ALGORITHMS : FLOYD-WARSHAL -Displaying DISTANCE MATRIX and PI MATRIX using C PROGRAM

Modify the following Floyd-Warshall algorithm by introducing a π( pi ) table as per the class’s discussion. Here you can write one function...