Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:25:10+00:00 2026-06-15T12:25:10+00:00

The assignment was to create a program that computes the Ackermann equation using recursion,

  • 0

The assignment was to create a program that computes the Ackermann equation using recursion, which I successfully did. Part of the assignment says:

“The function should print the number of recursive function calls which are multiple of k. Set k = 100 for
values of n; m <= 3, and k = 1; 000; 000 for all other values. Your program should also print the total number
of function calls made.”

The ackermann function is supposed to print out the number of function calls and recursive functions calls, but I can’t figure out how to do it. Any help would be great. Thanks!

This is what I have so far:

#include <stdio.h>

//function to compute the end result ackermann equation
int ackermann (int n, int m)
{
    int result = 0;

    if (n == 0)
    {
        result = m + 1;

    } else if (m == 0)
    {
        result = ackermann(n - 1, 1);

    } else
    {
        result = ackermann(n - 1, ackermann(n, m - 1));
    }

    return result;
}

//main function
int main(int argc, const char * argv[])
{
    char ans = 'y';
    int m, n, result;

    printf("\n\n------Ackermann Function------");

    while (ans == 'Y' || ans == 'y') {
        printf("\nPlease enter n: ");
        scanf("%d", &n);

        printf("\nPlease enter m: ");
        scanf("%d", &m);

        result = ackermann(n, m);

        printf("\nResult: %d", result);

        printf("\n\nDo you want to go again? ");
        scanf(" %c", &ans);
    }

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:25:11+00:00Added an answer on June 15, 2026 at 12:25 pm
    static int count = 0;
    
    int func() 
    {
      count ++
      // do your work
      // recursive call
    }
    

    Make static variable which will keep the total number of calls made to functions.

    And in this case you don’t have to make count as global making it local static into function is enough because static variable retains it’s value as static has file scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an assignment which to create a program that can read
As part of an assignment I need to create a shipping program that checks
For a school assignment I have to create a C++ program that will create
For an assignment, we were asked to create a function which returns an inverse
I was given the assignment to create a program that performs basic set operations.
I am trying to complete my assignment.which says In a Distance class create an
I have an assignment to create a program that prompts user input of an
I've been given an assignment to create a program that might involve a quiz
Iam writing a simple Java program for an assignment,which implements a library system using
As a school assignment, I am supposed to create a program in C# that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.