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

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
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.