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

Dll, i need amibroker afl to dll plugin

i need amibroker afl to dll plugin

ASCII, A string S is said to be "Super ASCII", if it contains the character...

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

What are source files and bytecode files, Problem : (a) What do you u...

Problem : (a) What do you understand by the term ‘constructor' in Java? Explain with an appropriate example. (b) Describe the differences between an object and a class usi

Difference between mutex and binary semaphore, Semaphore is used to synchro...

Semaphore is used to synchronize processes. whereas mutex is used to give synchronization among threads running in the similar process.

Explain about the unions, Explain what are Unions? The Unions like as s...

Explain what are Unions? The Unions like as structures, contain members whose individual data types may perhaps differ from one another. Though the members that create a union

I need p2p video streaming, Project Description: P2P media streaming bro...

Project Description: P2P media streaming browser (IE, Chrome, Firefox) plug-in needed that is compatible with Win Xp,7,8 that is Windows Firewall friendly Example like Swarm

Encoding and decoding, program for decode the encoded numbering format into...

program for decode the encoded numbering format into message

Need cron job parsing json from api, Need Cron Job Parsing JSON from API, I...

Need Cron Job Parsing JSON from API, Inserting in to DB Project Description: The Project is to prepare a Cron Job with an adjustable interval in seconds and milli seconds. Cr

Program for dynamic 2d memory, Requirements: 1.  This assignment as well...

Requirements: 1.  This assignment as well as other assignments in this class must be finished on Windows operating system. 2.  Zip your program and submit the zip file on ANG

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