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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:51:28+00:00 2026-05-26T04:51:28+00:00

its function subtotalspool. It says i cant use it as a function somewere inside

  • 0

its function subtotalspool. It says i cant use it as a function somewere inside int main and it says in function subtotalspool that the varriable spoolnumber wasnt declared. I put “int spoolnumber” in the function declaration for subtotalspool. is there something im missing?
EDIT for code change

/**************************************************/
/* Author:     Samuel LaManna                     */
/* Course:     CSC 135 Lisa Frye                  */
/* Assignment: Program 2 Functions                */
/* Due Date:   10/11/2011                         */
/* Filename:   program2.cpp                       */
/* Purpose:    This progam will accept input and  */
/*             give user shipping and total cost  */
/*             for a shippment of spools of wire  */
/**************************************************/


#include <iostream>

using namespace std;

void instruct();     //Function Declaration for instruction function
int spoolnum();      //Function for number of spools input
int stotalspool(int spoolnumber); //Function to calculate the sub total 
float shippingcost();//Function to calculate shipping cost
void results();      //Function to display all of the costs and a final total


int main()
{
  int spoolnumber;     //Var for number of spools to be ordered
  int subtotalspool;   //Var for spool sub total

  instruct();          // Function call to print instructions to user

  spoolnumber = spoolnum(int spoolnumber );
  //Test output to make sure/show that input given in function is retained in int main
  cout << endl << "Value stored in variable spollnumber inside int main is: " <<  spoolnumber << endl;

  subtotalspool = stotalspool();

  cout<< endl << "Value stored in variable subtotalspool inside int main is: " << subtotalspool << endl;

  return 0;
}



/********************************************/
// Name: instruct                            /
// Description: Print instructions to user   /
// Parameters: N/A                           /
// Reture Value: N/A                         /
/********************************************/

void instruct()
{
  cout << endl << "This program will calculate the shipping information " << endl
       << "for a batch of wire spools. " << endl << endl;

  return;
}

/********************************************/
// Name: spoolnum                            /
// Description: Ask for and get number of    /
// spools                                    /
// Parameters: N/A                           /
// Reture Value: spoolnum                    /
/********************************************/
int spoolnum()
{
  int spoolnum = 0;
  char type = 'n';

  do {
      cout << "Number of spools to be shipped: ";
      cin >> spoolnum;
      cout << endl;
      cout << spoolnum << " spool(s) of wire will be shipped" << endl;
      cout << "Is this correct? [y/n] ";
      cin >> type;
  } while (type != 'y');

  return spoolnum;
} 

/********************************************/
// Name: stotalspool                       /
// Description: Calculate the subtotal for   /
//the shipped spools                         /
// Parameters: N/A                           /
// Reture Value: stotalspool               /
/********************************************/
int stotalspool()
{
  int stotalspool;
  stotalspool = spoolnumber * 100;

  return stotalspool;
}
  • 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-05-26T04:51:28+00:00Added an answer on May 26, 2026 at 4:51 am

    Your variable spoolnumber is only defined on the scope of the function main. You either need to call spoolnum() in your subtotalspool() function, or pass that variable into the function to operate on it appropriately.

    EDIT
    To pass a variable to a function, you need to change its signature. For instance, int subtotalspool(int x) will give you a copy of the value of whatever you pass in. You would then call this function as follows sts = subtotalspool(spoolnumber); Then in your actual function code (if in your signature you used the variable name x) you should change all of your code in this function which uses spoolnumber variable and replace that with x

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

Sidebar

Related Questions

I'm trying to use usort() and leverage a global variable inside its function scope,
I have a thread that, when its function exits its loop (the exit is
I have some code within one function that I want to separate into its
I'm building a Facebook app that has (as part of its function) a display
I have a UIPanGestureRecognizer on a view inside of a UIScrollView. Its function is
Is there any way how to set std::setw manipulator (or its function width )
How do I automate the process of getting an instance created and its function
I have a custom UITableViewCell. In its function - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier, I need
I'm creating an application in C#. Its function is to evaluate if a given
I've got a (mostly) working plugin developed, but since its function is directly related

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.