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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:41:11+00:00 2026-05-23T14:41:11+00:00

When adding this code to a simple calculator program I receive the error message

  • 0

When adding this code to a simple calculator program I receive the error message “Control reaches end of non-void function”.

Now after reading some response I know that I should be adding a return call so that the program doesn’t hang up in the instance that the accumulator is not set but I want to know where to place it or which would be the proper way to phrase this.

Thanks, any help would be appreciated. I can provide the full program code if necessary as well.

-(double) changeSign
{
accumulator = -accumulator;
}

-(double) reciprocal
{
accumulator = 1/accumulator;

}

-(double) xSquared
{
accumulator = accumulator * accumulator;
}
  • 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-23T14:41:11+00:00Added an answer on May 23, 2026 at 2:41 pm

    Very simply, each of the methods you have here is declared to return a double, but you never actually return anything.

    You need to do something like:

    -(double) changeSign
    {
    accumulator = -accumulator;
    return accumulator;
    }
    

    Or, alternatively, if you don’t intend to return the new value of accumulator, change the return type to void:

    -(void) changeSign
    {
    accumulator = -accumulator;
    }
    

    ps. the issue is not that the program will “hang up in the instance that the accumulator is not set”. It’s that you are saying “Here a method that returns a double“, but the code does not actually return anything. The error message means “I got to the end of this function that you promised would return something, but you seem to have forgotten”.

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

Sidebar

Related Questions

I'm currently adding some new extended classes to this code: foreach (BaseType b in
HI, I have this code for extracting the href and adding it to a
Can anyone tell me what the correct Plinq code is for this? I'm adding
I am getting this error after adding the libxml2.2.dylib file Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1
I'm doing a simple program using arraylist. But I've encountered an error. After deleting
This simple code is not producing any sound on a couple of machines that
consider this simple code: echo iconv('UTF-8', 'ASCII//TRANSLIT', 'è'); it prints `e instead of just
I am adding this simple plugin that I have working in a static html
I am using this code to have a simple gallery on the page: <?php
I'm having a memory problem related to UIImageView. After adding this view to my

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.