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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:57:42+00:00 2026-05-11T01:57:42+00:00

I’m a junior student in IT. I am facing a problem with the output

  • 0

I’m a junior student in IT. I am facing a problem with the output of the program. The idea of the program is that I should use functions to read an array of 10 elements, then get the average of the elements, then get the the max and min. I’ve got the max and min right but the average is showing weird stuff. Please check the code and tell me what should I do or help me in some way or another.

The out put is (notice that is requesting for 11 numbers instead of 10 and if I change the loop parameters to let it take only 10 then it’s showing weird stuff

enter the group of integers numbers 1 2 3 4 5 6 7 8 9 0 9  1 2 3 4 5 6 7 8 9 0the avg is 3.500000 9 1Press any key to continue . . .  // func-sortarray.cpp : Defines the entry point for the console application. //  #include 'stdafx.h' #define size  10  void readarray(int []); void average(int []); void printArray(int []); void max(int []); void min(int []);  int _tmain(int argc, _TCHAR* argv[]) {     int sarray[size];     readarray(sarray);     printArray(sarray);     average(sarray);     max(sarray);     min(sarray);     return 0; }  void readarray(int a[]) {     printf('enter the group of integers numbers\n');     for (int i=0; i<=size-1 ;i++)         scanf('%d\n',&a[i]); }  void average(int a[]) {     int i;     double avg;     double total = 0;     for (i=0; i <= size-1; i++)     {         total = total + a[i];     }      avg = total /size-1;     printf('the avg is %f\n',avg); }  void printArray(int a[]) {     int j;     for (j = 0; j <= size - 1; j++)          printf( '%2d', a[ j ]); }  void max(int a[]) {     int ma =a[0];      for (int j=0;j<size-1;j++)     {         if (ma<a[j])             ma=a[j];     }     printf('%d',ma); }  void min(int a[]) {     int mi =a[0];      for (int j=0;j<size-1;j++)     {         if (mi>a[j])             mi=a[j];     }     printf('\n%d',mi); } 

thanx in advance

  • 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. 2026-05-11T01:57:43+00:00Added an answer on May 11, 2026 at 1:57 am

    It is skipping the first input number because of the ‘\n’ in the scanf() string. To fix it, remove the ‘\n’ from the scanf string, like this:

    scanf('%d', &a[i]); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Pass the address of the integer, not the integer itself.… May 11, 2026 at 1:39 pm
  • added an answer In addition to xsel and xclip already mentioned there is… May 11, 2026 at 1:39 pm
  • added an answer In Delphi 2009, there is the ability to have a… May 11, 2026 at 1:39 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.