#include <stdio.h>

#define REF_TEMP 20
#define COEFF_CU 4.041e-3
#define COEFF_AL 4.308e-3

float rCalc(float temp, float rRef, float coeffNum);
float rRefCalc(float rPerLength, float length);

void main()
{

    float temp;
    float length;
    float rPerLength;

    printf("This program calculates the resistance of aluminium and copper coils and at given temperature (in degrees Celsius) and length\n");

    printf("Enter the temperature in Celsius: ");
    scanf("%f", &temp);

    printf("Enter coil length: ");
    scanf("%f", &length);

    printf("Enter resistance per length of given coil: ");
    scanf("%f", &rPerLength);

    float rRef = rRefCalc(rPerLength, length);
    float rAl = rCalc(temp, rRef, COEFF_AL);
    float rCu = rCalc(temp, rRef, COEFF_CU);

    printf("The resistance of an aluminium coil at temperature %f degrees Celsius with ", temp);
    printf("length %f meters, ", length);
    printf("is: %f ohms\n", rAl);

    printf("The resistance of a copper coil of the same temperature and length is: %f ohms\n", rCu);

}

float rCalc(float temp, float rRef, float coeffNum)

{   
    float r = rRef*(1+coeffNum*(temp - REF_TEMP));
    return r;
}

float rRefCalc(float rPerLength, float length)

{
    float rRef = rPerLength * length;
    return rRef;
}