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;
float sum, average;
for (i = 1;i <=10;i++)
{
/*Load up the array with the data*/
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 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. Explain about the integer constants in c language, Explain about the Intege...

Explain about the Integer constants in c language? An integer constant is the integer valued number and it refers to a sequence of digits. A decimal integer constant includes o

String, A string is said to be "Beautiful"€, if it contains only non repet...

A string is said to be "Beautiful"€, if it contains only non repetitive alphabets

How do you connect a c++ program to c functions?, A: Using the extern "C" l...

A: Using the extern "C" linkage specification around the C function declarations. Programmers must know about mangled function names and type-safe linkages. After that they must

I want a craiglist poster required, Project Description: I want someone ...

Project Description: I want someone who can post ads for me on Craiglist . I will pay 3\$ per ad i need about 30-40 ads per day . Skills required: C Programming, MySQL, Jav

Explain multilevel inheritance, Multilevel Inheritance In multilevel in...

Multilevel Inheritance In multilevel inheritance there is a parent class , from whom we derive another class . now from this derived class we can derive another class and so on

Fraction coding, Create a program that asks the user for two integers which...

Create a program that asks the user for two integers which represent the numerator and denominator parts of fraction. Print out a simplification of the fraction. Example: Enter th

Compiler design limiting instruction, Ravi is a newbie to the programming a...

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules: Ã‚Â· Each program must start with ''''{'''' and end with ''''}

Asset pricing project, In the final project assignment you are asked to dev...

In the final project assignment you are asked to develop an OOP C++ class hierarchy for derivative pricing, using the binomial tree and Black-Scholes option pricing methods. You wi

Discount program, Build a program that calculates a discount for items base...

Build a program that calculates a discount for items based on quantity bought each item is \$99.99 Ask user to enter the quantity of the items Get the quantity of items from the u

Program of sorting algorithms , The program sorting.cpp contains a main f...

The program sorting.cpp contains a main function for testing the operation of several sort algorithms over various data sizes and data set organisations. The program understands  