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

  • Home
  • SEARCH
  • 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 8925955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:50:15+00:00 2026-06-15T07:50:15+00:00

I want use two functions with recurrence in the same time, and I have

  • 0

I want use two functions with recurrence in the same time, and I have a problem:

I have two functions. Each use other function from the same header file. But when I want use below function in above function, I have an error. I know, what happened, but I don’t know how to fix it. My code:

Main.cpp:

include <iostream>
#include <cstdlib>
#include <C:\Users\Natch\Documents\CPP\Calc\incls.h>
using namespace std;

//Global vars



//Global functions




//Main program


int main() {
menu(1);
system("pause");
}

Incls.h:

#ifndef INCLS_H_INCLUDED
#define INCLS_H_INCLUDED



#endif // INCLS_H_INCLUDED

#include <iostream>
#include <cstdlib>

using namespace std;
//Vars

int a, b, func, sa, ctrl;
long double sum, sqrt;

//Voids
void down(int func) {
 if (func < 6) {
          cout << "Wprowadz pierwszy skladnik dzialania:" << endl;
          cin >> a;
          cout << "Wprowadz drugi skladnik dzialania:" << endl;
          cin >> b;
          switch(func){
              case 1:
                sum = a+b;
                cout << "Wynik wynosi: " << sum << endl;
                menu(2);
                break;
              case 2:
                sum = a-b;
                cout << "Wynik wynosi: " << sum << endl;
                break;
              case 3:
                sum = a*b;
                cout << "Wynik wynosi: " << sum << endl;
                break;
              case 4:
                sum = a/b;
                cout << "Wynik wynosi: " << sum << endl;
                break;
              case 5:
                sum = a%b;
                cout << "Wynik wynosi: " << sum << endl;
                break;
          }
 }else if (func == 6)
 {
       cout << "Podaj ilosc liczb do obliczenia sredniej:" << endl;
       cin >> sa;
 }else if (func == 7)
 {
       cout << "Podaj liczbe do wyciagniecia pierwiastka:" << endl;
       cin >> a;
 }else if (func == 8)
 {
       cout << "Podaj liczbe do wyciagniecia potegi:" << endl;
       cin >> a;
 }else if (func== 9)
 {
     system("exit");
 }
}

void menu(int ctrl) {
if (ctrl==1){
    system("cls");
    system("color 06");
    cout << "Kalkulator" << endl;
    cout << "Wybierz funkcje: " << endl;
    cout << "1.Dodawanie" << endl;
    cout << "2.Odejmowanie" << endl;
    cout << "3.Mnozenie" << endl;
    cout << "4.Dzielenie" << endl;
    cout << "5.Reszta z dzielenia" << endl;
    cout << "6.Srednia arytmetyczna" << endl;
    cout << "7.Pierwiastek kwadratowy" << endl;
    cout << "8.Potega n^2" << endl;
    cout << "9.Wyjscie" << endl;
    cout << "Twoj wybor:" << endl;
    cin >> func;
    down(func);
}else if (ctrl==2){
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    menu(1);
}
}
  • 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-15T07:50:17+00:00Added an answer on June 15, 2026 at 7:50 am

    Firstly, the word you’re probably looking for is “recursion”. You might want to be a little bit careful here, because by having functions repeatedly call each other during normal operation like this, you may eventually run out of stack space. A more detailed explanation of what this actually means is outside of the scope of this answer, but you’d probably be better using a conventional while loop instead of recursion in this case.

    Secondly, when you get an error, please tell us what it is! Don’t make us guess, especially as there’s no guarantee that what you’re seeing will be the same error as we see when we run your program.

    Thirdly, tell us what platform and compiler you’re using. I’m assuming you’re using windows, given system("cls"), but again: don’t make us guess.

    Now, the actual error. I get this:

    test.h: In function ‘void down(int)’:
    test.h:30: error: ‘menu’ was not declared in this scope

    What you need is a “function prototyp” which describes the interface of the menu function before it is actually defined. Just stick

    void menu(int);
    

    above the definition of down, and you’ll find the compile error goes away. Whether the application runs as intended after that I don’t know, because you haven’t given enough information!

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

Sidebar

Related Questions

I want to use wx.CallLater: I have two functions and they shall call each
I want to use two different Spring web contexts , each have own contextConfig,
Example I want use the_excerpt in two locations. On functions.php I add function new_excerpt_length($length)
i have two functions and one of them call the other one. I want
I have problem with not members of a class functions. I want to use
if i have two functions that been called from ajax and i want to
Scenario I have a windows forms application. I want to use two different WCF
I want to use these two classes from lucene - import org.apache.lucene.analysis.snowball.*; import org.apache.lucene.analysis.PorterStemmer;
I've got two functions and one problem. hideTable(); ajaxCall(params); The function hideTable function hideTable()
I've defined a util.h file with functions that i want to use throughout several

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.