Finish the following functions in C language 1 void vectorin
Finish the following functions (in C language):
1. void vector_input(float v[],int n): input the elements of vector v and store in the
array. (15 points)
2. void vector_output(float v[],int n): output the elements of vector v on the screen.
(15 points)
3. void vector_add(float v1[],float v2[],float v3[],int n): calculate the sum of vector v1
and v2 and store the result in v3. The sum is a vector, not a single value. (20
points)
4. void vector_multiply(float v[],int n,float x): multiply each element in v by x (15
points)
5. float inner_product(float v1[],float v2[],int n): return the inner product of vector v1
and v2. (20 points)
6. float length(float v[],int n): return the length of vector v (15 points)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
file.c
#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)
 {
 }
Solution
void vector_input(float v[],int n)
 {
 printf(\"Enter %d values \",n);
 for ( int j=0;j< n;j++){
 printf(\"enter the integer number %d\ \", x);
 scanf(\"%f\", &v[j]);
 }
 }
 ----------------------------------------------------------
 void vector_output(float v[],int n){
 printf(\"Values in vector are: \ \");
 for (int j=0; j<n; j++)
 {
 printf(\"%d ,\", v[j] );
 }
 ----------------------------------------------------------------------
  void vector_add(float v1[],flaotv2[],float v3[],int n){
 int j;
 float v3[];
 for( j =0;j<n;j++)
 {
 v3[j]= v1[j] + v2[j];
 }
 System.out.println(\"vector_add: \");
 for ( j=0; j<n; j++)
 {
 printf(\"%d ,\", v3[j]);
 }
 }
 -------------------------------------------------------------------
  void vector_multiply(float v1[],float x,int n){
 int j;
 for( j =0;j<n;j++)
 {
 v1[j]= x * v2[j];
 }
 System.out.println(\"vector_multiply: \");
 for ( j=0; j<n; j++)
 {
 printf(\"%d ,\", v1[j]);
 }
 }
 ----------------------------------------------------------------------
  float inner_product(float v1[],float v2[],int n){
 int j;
 float inner_prd=0;
 float v3[n];
 for(j=0;j<n;j++){
 v3[j]=v1[j]*v2[j];
 }
 for(j=0;j<n;j++){
 inner_prd=inner_prd+v3[j];
 }
 System.out.println(\"Inner_product is %f:\",inner_prd);
 }
 -------------------------------------------------------------------------
  float length(float v[],int n){
 int j;
 float len=0;
 for(j=0;j<n;j++){
 len=len+(v[j]*v[j]);
 }
 printf(\"Length: %lf \",sqrt(len));
 }
![Finish the following functions (in C language): 1. void vector_input(float v[],int n): input the elements of vector v and store in the array. (15 points) 2. voi Finish the following functions (in C language): 1. void vector_input(float v[],int n): input the elements of vector v and store in the array. (15 points) 2. voi](/WebImages/39/finish-the-following-functions-in-c-language-1-void-vectorin-1119527-1761595424-0.webp)
![Finish the following functions (in C language): 1. void vector_input(float v[],int n): input the elements of vector v and store in the array. (15 points) 2. voi Finish the following functions (in C language): 1. void vector_input(float v[],int n): input the elements of vector v and store in the array. (15 points) 2. voi](/WebImages/39/finish-the-following-functions-in-c-language-1-void-vectorin-1119527-1761595424-1.webp)
![Finish the following functions (in C language): 1. void vector_input(float v[],int n): input the elements of vector v and store in the array. (15 points) 2. voi Finish the following functions (in C language): 1. void vector_input(float v[],int n): input the elements of vector v and store in the array. (15 points) 2. voi](/WebImages/39/finish-the-following-functions-in-c-language-1-void-vectorin-1119527-1761595424-2.webp)
