HI I am currently in a college level programming class studying C, I've been enjoying coding and have seriously thought about it as a career... up until now.
here is the link to the homework assignment if anyone is interested:
http://www.engineering.uiowa.edu/~cie/Homework/hw02.htm
In short I have to create 2 matricies using single string arrays, transpose them, add and subtract them.
I don't fully understand arrays and pointers but this is what I have, I'm sorry it's so long.
#include <stdio.h>
#define SIZE 100
void readarraya(float array[SIZE],int row, int col);
void printarray(float array[],int row, int col);
void transpose(float array[], int row, int col);
void readarrayb(float array[SIZE],int row, int col);
void matrixadd(float array[],int row,int col);
int main(){
int *a[SIZE];
int *b[SIZE];
int *c[SIZE];
int *row;
int *col;
readarraya(&a,&row,&col);
printarray(&a,&row,&col);
transpose(&a,&row,&col);
readarrayb(&b,&row,&col);
printarray(&b,&row,&col);
transpose(&b,&row,&col);
return 0;
}
void readarraya(float array[SIZE], int row, int col){
int i=0;
while (i==0);{
printf("How many rows would you like in the array?:");
scanf("%d",&row);
printf("How many columns would you like the in the array?:");
scanf("%d",&col);
if (row<0){
printf("Your rows need to be positive, please try again.");
}
else if (col<0){
printf("Your columns need to be positive, please try again.");
}
else if((col*row)>SIZE){
printf("The Size of the array is too big, try again.");
}
else
i=1;
}
int j=0;
printf("Enter the values of the array:");
for(j=0;j<SIZE;i++){
scanf("%f,",array[j]);
}
}
void printarray(float array[],int row, int col){
int i=0;
int j=0;
int k=0;
for (j=0;j<row;j++){
for(i=0;i<col;i++){
k=i*col+j;
printf("%f",&array[k]);
}
printf("\n");
}
}
void transpose(float array[],int row, int col){
}
void readarrayb(float array[SIZE], int row, int col){
int i=0;
while (i==0);{
printf("How many rows would you like in the array?:");
scanf("%d",&row);
printf("How many columns would you like the in the array?:");
scanf("%d",&col);
if (row<0){
printf("Your rows need to be positive, please try again.");
}
else if (col<0){
printf("Your columns need to be positive, please try again.");
}
else if((col*row)>SIZE){
printf("The Size of the array is too big, try again.");
}
else
i=1;
}
int j=0;
printf("Enter the values of the array:");
for(j=0;j<SIZE;i++){
scanf("%f,",array[j]);
}
}
void matrixadd(float array[],int row,int col){
}
Yes, it's bad but my question is: am I prompting the user for the matrix values in the right way?
printf("Enter the values of the array:");
for(j=0;j<SIZE;i++){
scanf("%f,",array[j]);
How would i convert the array to a matrix? i'm guessing using the row and col integers but i'm stumped
The transpose, add and subtract functions are way over my head. IF anyone could help me and tell me what i'm doing wrong so I can learn from my mistakes I would really appreciate it