my program is a 2-dimension array. i have to create an array of (3,4) size. first initialization. second fill random numbers. third find out the total of rows and columbs separately. and then print them. please help me i have to submit it tomorrow. please someone help me........
Answers (1)
well. since you just mentioned "in pseudocode"? here it is
start
declare a[3,4];
for i=0 to i=2 do
for j=0 to j=3 do
a[i,j] = generate_random_number();
end for
end for
declare sumRow = 0;
declare sumColumn = 0;
declare rowNum = 0;
declare columnNum = 0;
for k=0 to k=3 do
rowNum = rowNum + 1;
for m=0 to m=2 do
sumRow = sumRow + a[k,m];
end for
print "Sum of row " + rowNum + " is " + sumRow;
sumRow = 0;
end for
for p=0 to p=2 do
columnNum = columnNum + 1;
for n=0 to n=3 do
sumColumn = sumColumn + a[p,n];
end for
print "Sum of column " + sumColumn + " is " + sumColumn;
sumColumn = 0;
end for
end
thank you for your help. you take out your time for helping me it means a lot...
i want separate total of all rows and all columns.