Copy #include <stdio.h>
#include <stdlib.h>
void printVec(double *_vec, int _row);
int main()
{
// Static Matrix Allocation 1-D array
// fixed array size and initial constant values
double a[4] = { 1, 2, 3, 4 };
double b[] = { 2, 3, 4, 5 };
double c[4] = { 0 };
// Print 1-D array element
printVec(a, 4);
system("pause");
return 0;
}
void printVec(double *_vec, int _row)
{
for (int i = 0; i<_row; i++)
printf("Vector[%d] = %f \n", i, _vec[i]);
printf("\n");
}
Copy void main ()
{
// Exercise 1 ***********************************************
printf (“Exercise 1 \n ");
float x[4] = {1,2,3,4};
float y[4] = {5,6,7,8};
float out[4] = { 0 };
float out_dotProduct = 0;
int vecLength = 4;
addVec(x, y, out, vecLength);
printf(" addVector result (x + y): ");
printVec(out, vecLength);
system(" pause ");
}
Assign array address to pointer ptr.
Copy #include <stdio.h>
int main(){
int st[5] = { 1,2,3,4,5 };
int* ptr;
ptr = _______________;
for (int i = 0; i < 5; i++) {
// print each element by using pointer e.g. (ptr)
}
}