bratty_programmer, on 22 July 2011 - 03:19 AM, said:
I am given two arrays with numbers and i have to multiply them both to get the the third array which is the answer. My code is working but for some reason it's not multiplying the numbers correctly. The programme tends to give me the wrong answers for the third array. Maybe someone can take a look at it and guide me on what i am doing wrong please. The code is at the bottom
#include <stdio.h>
main(){
int array1[6]={4,20,55,24,60,10};
int array2[6]={2,30,10,12,20,33};
int array3[6];
printf("\n\nArray one(1):\t");
for (int i=0;i<6;i++){
printf("%d\t",array1[i]);
}
printf("\n\nArray two(2):\t");
for (int j=0;j<6;j++){
printf("%d\t",array2[j]);
}
printf("\n\n------------------------------------------------------------");
printf("\nResult of multiplying Array1 by Array2:");
printf("\n\nArray three(3):\t");
//for (i=0;i<6;i++);
//for (j=0;j<6;j++);
for(int k=0;k<6;k++){
array3[k]=(array1[i]*array2[j]);
printf("%d\t",array3[k]);
}
}
This post has been edited by macosxnerd101: 21 July 2011 - 08:23 PM
Reason for edit:: Please use code tags

New Topic/Question
Reply



MultiQuote




|