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 8085475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:07:46+00:00 2026-06-05T18:07:46+00:00

#include <iostream> #include <string.h> using namespace std; int main() { int e=0; int b=0;

  • 0
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    int e=0;
    int b=0;
    cout<<"Enter Exponent";
    cin>>e;
    cout<<"Enter Base";
    cin>>b;
    pow(e, b);
    cout<<"Power:"<<e;
    return 0;
}

void pow(int e, int b)
{
  int t=1;
  while(b==t)
  {
    e=e*b;
    t++;
  }
}

Here is the error I received:

ulaga.cpp|29|error: 'pow' was not declared in this scope

Can any one explain why this error occurred?

  • 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-05T18:07:49+00:00Added an answer on June 5, 2026 at 6:07 pm

    The C++ compiler parses through your code file sequentially in order. i.e. line 1 then line 2 then line 3… and so on. So by the time the compiler comes to the function call statement pow(e, b); in your main() function, it hasn’t yet reached the definition of the function void pow(int e, int b) below the main() function and therefore gives you the error. There are two ways to solve this.

    1) Move the definition of void pow(int e, int b) (and any other function that you plan to call from main()) above the main() function itself. This way the compiler has already parsed and is aware of your function before it reaches the pow(e, b); line in your main().

    2) The other way is to use a forward declaration. This means adding the line void pow(int e, int b); before the main() function. This tells the compiler that the function given by the forward declaration (in this case void pow(int e, int b)) is defined in this code file but may be called before the definition code of the function in the file. This is a better method as you may have multiple functions in your file calling one another in different order and it may not be easy to rearrange their definitions to appear before they are called in a file. Here’s a good read on Forward Declaration

    You may also want to pass parameters by reference to your function to get the correct result. i.e. use void pow(int& e, int& b). This will cause the values modified in your pow() function to actually be applied to integers e and b and not just to their copies which will be thrown away after pow() is done executing. This link about passing arguments by reference in functions is pretty good at explaining this.

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

Sidebar

Related Questions

#include<iostream> #include<string> using namespace std; int main() { int i; cout<<enter ur no. plz;
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(void) {
Here's my code so far: #include<iostream> #include<string> #include<fstream> using namespace std; int main() {
#include<fstream> #include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ ifstream infile; ofstream outfile; infile.open(oldfile.txt);
//Writing a letter #include <iostream> using namespace std; int main() { string first_name; //Name
#include <iostream> #include <string> using namespace std; void bubbleSort(int data[], int n); int main()
#include<iostream> #include<string.h> using namespace std; char * reverse (char *); int main() { char
#include <iostream> #include <string> #include <fstream> using namespace std; int main() { char x[20];
#include <iostream> using namespace std; int main() { struct list { string name; int
#include<iostream> #include<string> using namespace std; int main() { int list[25],vote[25]; bool found; int count,first,mid,last;

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.