/* Write a function that receives as input two float numbers (a and b), it multiplies them and it returns the result of the multiplications. The function must be applied to a vector of name vet in order to multiplicate by 3.0 each element of the vector. The result of the multiplication must be stored in a vector of name res with the same dimension of vet. */ #include #define SIZE 10 /* Prototype */ float mul(float a, float b); int main(){ float vet[SIZE] = {1.0, 5.0, 3.0, 7.0, 10.0, 1.0, 2.0, 3.0, 4.0, 5.0}; float res[SIZE]; int i; /* Multiplication of each element of vet by 3.0 and storing of the result in res */ for(i=0; i < SIZE; i++){ res[i] = mul(vet[i], 3.0); } /* Print results, i.e., the content of vector res */ for(i=0; i < SIZE-1; i++){ printf("%f ", res[i]); } printf("%f\n", res[SIZE-1]); return 0; } /* Implementation of the function mul that performs the multiplication between a and b */ float mul(float a, float b){ float result; result = a*b; return result; } /* The function mul can be also implemented in the following way */ /* float mul(float a, float b){ return a*b; } */