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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:29:45+00:00 2026-06-12T15:29:45+00:00

I’m writing a statistical calculator, with 3 different calculation options. The problem is whenever

  • 0

I’m writing a statistical calculator, with 3 different calculation options. The problem is whenever I choose the 2nd option, it wants to print both the answer from the 1st option and the 2nd option. When I choose the 3 option, it just prints the answer the the 3rd option(the wrong answer, but thats probably a mishap in the formula). Here is the results:

Please Enter a number of inputs
3
Please enter number 1
1
Please enter number 2
2
Please enter number 3
3
Statistical Calculator Menu
(1) Mean
(2) Standard Deviation
(3) Range
(4) Restart/Exit
2
Here is the Mean 2.0Standard Devition is 0.8

Now I thought it might be an issue with how I’m calling each function, but the best I can tell thats not the case. Then I thought it might be a value that I didn’t initialize, but it seems as though thats not it either. I just need another pair of eyes to see where I went wrong here.

#include <stdio.h>
#include <conio.h>
#include <math.h>

const int MAX_DATA=8;
void menu(float numbers[], int amount);
float mean(float numbers[],int amount);
float standard_dev(float numbers[], int amount);
float range( float numbers[], int amount);

int main()
{
    int i=0, amount=0;
    float numbers[MAX_DATA];
    printf("Please Enter a number of inputs \n");
    scanf("%d", &amount);
    if (amount>MAX_DATA)
    {
        printf("You entered too many numbers");
    }
    else
    {
        for (i=0; i<amount; i++)
        {
            printf("Please enter number %d\n", i+1);
            scanf("%f",&numbers[i]);
        }
        menu(numbers,amount);
    }
    getch();
    return 0;
}
void menu(float numbers[],int amount)
{
    int input2=0;
    printf("Statistical Calculator Menu");
    printf("\n(1) Mean\n(2) Standard Deviation\n(3) Range\n(4) Restart/Exit\n");
    scanf("%d",&input2);
    if(input2==1)
    {
        mean(numbers,amount);
    }
    if  (input2==2)
    {
        standard_dev(numbers,amount);
    }
    if (input2==3)
    {
        range(numbers,amount);
    }
}
float mean(float numbers[],int amount)
{
    int i;
    float sum=0;
    float average=0;
    for (i=0; i<amount; i++)
    {
        sum=sum+numbers[i];
    }
    average=sum/amount;
    printf("Here is the Mean %.1f", average);
    return average;
}
float standard_dev(float numbers[], int amount)
{
    float sdev=0,dev=0,sumsqr=0,variance=0;
    int i;
    float mean2=0;
    mean2=mean(numbers,amount);
    for (i=0; i<amount; i++)
    {
        dev=numbers[i]-mean2;
        sumsqr+=dev*dev;
    }
    variance=sumsqr/(float)amount;
    sdev=sqrt(variance);
    printf("Standard Devition is %.1f", sdev);
    return sdev;
}
float range(float numbers[],int amount)
{
    int i;
    float diff=0;
    for (i=0; i<=amount; i++)
    {
        diff=numbers[amount]-numbers[1];
    }
    printf("%f\n",diff);
    return diff;
}
  • 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-12T15:29:46+00:00Added an answer on June 12, 2026 at 3:29 pm
    float standard_dev(float numbers[], int amount)
    {
     float sdev=0,dev=0,sumsqr=0,variance=0;
     int i;
     float mean2=0;
     mean2=mean(numbers,amount); // Here it is.
    

    It calls the mean function, which actually prints something 🙂 You can add boolean flag shouldPrint to functions and pass it as true when you want to print it.

    Also, this problem is easily solvable with simple debugging your code…if actually looking at it doesn’t seem to help…

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

Sidebar

Related Questions

I've tracked down a weird MySQL problem to the two different ways I was
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.