Question
Write a C program that declares three single dimensinal arrays named miles, gallons, and mpg. Each array should be capable of holding 10 elements. In the miles array store the numbers 240.5, 300.0, 189.6, 310.6, 280.7, 216.9,199.4, 160.3, 177.4, 192.3. In the gallons array store the numbers 10.3, 15.6, 9.7, 14, 16.3, 15.7, 14.9, 10.7, 9.3, 9.4. Each element of thempg array should be calculated corresponding to the miles and gallons element. I.E. mpg[0]=miles[0]/gallons[0]. Use pointers when calculating and displaying the elements of the mpg array
Explanation / Answer
#include int main() { int i; float miles[] = {240.5, 300.0, 189.6, 310.6, 280.7, 216.9,199.4, 160.3, 177.4, 192.3}; float gallons[] = {10.3, 15.6, 9.7, 14, 16.3, 15.7, 14.9, 10.7, 9.3, 9.4}; float mpg[10]; for (i=0; i