Here's the program.
the goals are:
1. user inputs values
2. displayMatrix() displays array and its values
3. user inputs multiplier value
4. scalarMultiply() multiplies values by whatever user input was
5. displayMatrix() displays array and new values
i'm stuck on no. 4
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
void displayMatrix(int *value){
int i;
printf("Here is your array: \n\n");
for(i=0;i<SIZE;i++){
printf("In element [%i] is %i\n\n",i+1,value[i]);}
}
int scalarMultiply(int value[],int mult){
int i,sum=0;
for(i=0;i<SIZE;i++){
sum=value[i] * mult;
}
return sum;
}
main(){
int givenVal[SIZE],matrix,i,multiplier;
for(i=0;i<SIZE;i++){
printf("enter values for array: ");
scanf("%i",&givenVal[i]);
}
displayMatrix(givenVal);
printf("Enter value of multiplier: ");
scanf("%i",&multiplier);
matrix=scalarMultiply(givenVal[SIZE],multiplier);
displayMatrix(givenVal);
system("pause");
}
It runs, however when it gets to the part that the user enters the value to be multiplied by, it says "Unhandled exception at 0x00411443 in matrix.exe: 0xC0000005: Access violation reading location 0xcccccccc." then when i got to check out the problem, it shows it happening at "sum=value[i] * mult;" and the error message there says,"error: expression cannot be evaluated"(it shows a value for "sum" and "mult" in the output under the compiler, but "value[i]" has the latter error message.)
please help!