Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is a demo code please use C language (hw2.c) file is #include <stdio.h> voi

ID: 3666409 • Letter: T

Question

this is a demo code

please use C language

(hw2.c) file is

#include <stdio.h>

void vector_input(float v[],int n);
void vector_output(float v[],int n);
void vector_add(float v1[],float v2[],float v3[],int n); //v3=v1+v2
void vector_multiply(float v[],int n,float x); //v=v*x
float inner_product(float v1[],float v2[],int n); //return v1.v2
float length(float v[],int n);

int main()
{
   return 0;
}

void vector_input(float v[],int n)
{
}

void vector_output(float v[],int n)
{
}

void vector_add(float v1[],float v2[],float v3[],int n) //v3=v1+v2
{
}

void vector_multiply(float v[],int n,float x) //v=v*x
{
}

float inner_product(float v1[],float v2[],int n) //return v1.v2
{
}

float length(float v[],int n)
{
}

Introduction 1. The deadlie of submission is February 15th. Acceptable file format for submission is C source file, not a text file, archive file, word document or executable file. 2. Check your program carefully before submission. Test data differs from the sample program work properly for all input will be used in the grading. Make sure your possible cases. 3. You just need to fill the content of hw2.c, do not change the form of the function. It is fine that the main function remains blank Functions Finish the following functions in hw2.c. 1. void vector input(float v.int n): input the elements of vector v and store in the array. 15 points) (15 points) and v2 and store the result in v3. The sum is a vector, not a single value. (20 2. void vector output(float v,int n): output the elements of vector v on the screen. 3. void vector add( float v1[],float v2],float v3],int n): calculate the sum of vector ul 4. void vector.multiply(float v[],int n,float x): multiply each element in u by z (15 5. float inner-product(float v1[,fioat v2ll,int n): return the inner product of vector v1 6. float length(float vl,int n: return the length of vectorv (15 points) points) points) and v2. (20 points) Sample Input and Output 1. vector_add: (1.2, 3.5, 5.7)+(3.2, 1, 6.3)-(4.4, 45, 12) 2. vector multiply: (2.2, 4.1, 6.5)x3 (6.6, 12.3, 19.5) 3. inner-product: (1,2,3)-(4,5,6)-1x4+2x5+3x6-4+10+18-32 4, length: length of vector (3,4,5) is V94 164 25-V50 = 7.071068

Explanation / Answer

#include <stdio.h>
void vector_input(float v[],int n);
void vector_output(float v[],int n);
void vector_add(float v1[],float v2[],float v3[],int n); //v3=v1+v2
void vector_multiply(float v[],int n,float x); //v=v*x
float inner_product(float v1[],float v2[],int n); //return v1.v2
float length(float v[],int n);
int main()
{
}
void vector_input(float v[],int n)
{
   int i;
   for(i=0;i<n;i++)
       scanf("%f",&v[i]);
}
void vector_output(float v[],int n)
{
   int i;
   printf("(");
   for(i=0;i<n;i++)
       printf("%f,",v[i]);
   printf(")");
}
void vector_add(float v1[],float v2[],float v3[],int n) //v3=v1+v2
{
   int i;
   for(i=0;i<n;i++)
       v3[i] = v1[i] + v2[i];
}
void vector_multiply(float v[],int n,float x) //v=v*x
{
   int i;
   for(i=0;i<n;i++)
       v[i] = v[i] * x ;
}
float inner_product(float v1[],float v2[],int n) //return v1.v2
{
   int i;
   float ip =0;
   for(i=0;i<n;i++)
       ip = ip + v1[i] * v2[i] ;
   return ip;
}
float length(float v[],int n)
{
   int i;
   float length = 0;
   for(i=0;i<n;i++)
       length = length + v[i] * v[i] ;
   length = sqrt(length);
   return length;
}