Write a program to calculate the average of ten numbers, C/C++ Programming

Assignment Help:

Write a program to calculate the average of ten numbers
 
    #include stdio.h
    /* Only this header is needed since only IO are used */
    void main()
    {   
      char prompt;
       int i;
        float b[12];
        float sum, average;
     for (i = 1;i <=10;i++)
      {
        /*Load up the array with the data*/
           printf("Please enter in your number \n\r");
           scanf("%f",&b[i]);
/* Note that the index must be an integer Whole number of boxes */
        }
    sum = 0.0;
    for (i = 1;i <=10;i++)
        {
        /* Calculate the sum of all the array elements*/  
           Sum += b[i];
        }
     printf("The average of the following numbers\n\r ");
    /* Display the numbers from the array */
     for (i = 1;i <=10;i++)
        {
           printf("%10.2f \n\r",b[i] );
        }
    /*Calculate the average and display it */
     average = sum / 10.0;
     printf("Is = %10.2f \n\r", Average ); 
    printf("Press any key to exit \n\r");
    scanf("\n%c",&prompt);
 
    }

Although we could have done this in one For loop, it shows that the numbers typed in are easily accessible any time within the program It is possible to extend the array to more than one dimension. Although with regards to memory there in no difference, we can consider each element (x) as a filing cabinet which contains (Y) files i.e.

        A[2][3] cabinet 2 file 3

This technique is useful in data processing and matrix manipulation for graphics and CAD applications. We can think of a 2 dimension array (2x2) as a grid or matrix. A better technique of storage is that of the structure.

1308_Write a program to calculate the average of ten numbers.png

 


Related Discussions:- Write a program to calculate the average of ten numbers

Function, write a function named "fact"that takes one integer arguments,ca...

write a function named "fact"that takes one integer arguments,call them "num" and returns as ..............

Assignment help, It''s that spooky time of year when the dead walk the Eart...

It''s that spooky time of year when the dead walk the Earth, things go bump in the night, and the Centers for Disease Control (CDC) recognizes the need for zombie preparedness (

Electrical eng, calculate the total resisitance of a series circuit?

calculate the total resisitance of a series circuit?

Is it legal for a member function to say delete this?, Is it legal for a me...

Is it legal for a member function to say delete this? A: As long as you're cautious, it's OK for an object to delete this. Here's how I define "cautious": You have to be a

develop a calculator in masm, Part 1 Assignment:  develop a calculator...

Part 1 Assignment:  develop a calculator in MASM. Text chapters covered:  1 through 4, 5.4, 5.5, 6.3, 7.4 You will develop a "calculator" algorithm in MASM using reverse-

Padovan string, write a program that counts the number of occurrences of th...

write a program that counts the number of occurrences of the string in the n-th Padovan string P(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

I need script for auto seating poker, Project Description: Not just like...

Project Description: Not just like that though. I want a similar program that can scan through poker lobbys (pokerstars, full tilt, ongame and ipoker) and seat me to the left of

I need poker room auto seat program, Project Description: I want a scrip...

Project Description: I want a script for an online poker site. It needs to be scanning all the required tables and when the table meets certain criteria it should take a seat at

Algorthrithm for c programe, Need algorithm for c programe #Minimum 100 wor...

Need algorithm for c programe #Minimum 100 words accepted#

C++ code??, Write a program to find the area under the curve y = f(x) betwe...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd