Changed "a" to pass by pointer
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void program_intro(void);
void input_read(float *a, float b, float c, float x_initial, float x_final, float x_delta);
int main()
{
float a, b, c, x_initial, x_final, x_delta;
program_intro();
input_read(&a, b, c, x_initial, x_final, x_delta);
printf("a = %2.f\n", a);
printf("b = %2.f\n", b);
printf("c = %2.f\n", c);
printf("x = %2.f\n", x_initial);
printf("x[i] = %2.f\n", x_final);
printf("delta X = %2.f\n", x_delta);
return 0;
}
void program_intro(void) //Explanation of program to the user
{
printf("This program will compute a range of values for\n");
printf("the second degree polynomial f(x) = ax^2 + bx + c,\n");
printf("the derivative f'(x) = 2ax + b, \n");
printf("the integral F(x[i]) = (a/3)x[i]^3 + (b/2)x[i]^2 + cx, and the\n");
printf("area A = F(x) - F(x[i]).\n\n");
return;
}
void input_read(float *a, float b, float c, float x_initial, float x_final, float x_delta)
{
printf("Please input the polynomial coefficients as follows:\n\n");
printf("Coefficient a: ");
scanf("%f", a);
printf("\nCoefficient b: ");
scanf("%f", &b);
printf("\nCoefficient c: ");
scanf("%f", &c);
printf("\n\nPlease input the range and increment to be tested as follows:\n\n");
printf("x: ");
scanf("%f", &x_initial);
printf("\nx[i]: ");
scanf("%f", &x_final);
printf("\ndelta x: ");
scanf("%f", &x_delta);
return;
}
Edit: Add link Pointers in C - Tutorial - Cprogramming.com
Please read the "Pointing to Something: Retrieving an Address" first example code till you understand it.
Tim S.