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

PEBBLE MERCHANT, C CODE FOR PEBBLE MERCHANTS PROBLEM

C CODE FOR PEBBLE MERCHANTS PROBLEM

Flight Departure in C, I really have a hard time analyzing how to write a c...

I really have a hard time analyzing how to write a code in C. It''s all bout Time Departure and we must used a 24 hour clock. Can u help me?

Oop, what is oop?

what is oop?

Define the data types of c language, Define the Data Types of c language? ...

Define the Data Types of c language? The C has a concept of 'data types' which are used to define a variable before its use and the definition of a variable will assign storage

C program to print fibonacci series upto n using recursion, C program to Pr...

C program to Print Fibonacci series upto n using recursion: int fibo(long int); void main() {                 long int a=0,n;                 printf ("how many term

Common concepts of object oriented, Object Oriented Programming Paradigm: ...

Object Oriented Programming Paradigm: For OOP, Paradigm is a standard set.  The OOP will help to develop software in modules, which will be integrated later as a full packag

Overloading unary operators using friend function, O v e r l o a d i ...

O v e r l o a d i n g U n a r y Op e r a t o r s Us i n g F r i e n d F u n c t i o n cl a ss s i g n { i n t a ,

C program for reverse the word in string, C Program for REVERSE THE WORD IN...

C Program for REVERSE THE WORD IN STRING #include conio.h> #include stdio.h> #include string.h> void main() {           char a[50],b[25][25],temp;           i

#title., #quGiven the Array class definition in Fig. 11.10-11.11 (pp. 476-4...

#quGiven the Array class definition in Fig. 11.10-11.11 (pp. 476-479) of the textbook, write a new overloaded operator function for the ‘%’ (modulus) operator (i.e., return an arra

Inside and outside type casting, depth description of the inside and outsid...

depth description of the inside and outside typecasting

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