# Hello, i need help finishing my code

• (4 Pages)
• 1
• 2
• 3
• Last »

## 56 Replies - 2283 Views - Last Post: 16 January 2013 - 03:38 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=307572&amp;s=e86c17ebdd8a874dd0fb213b1bb61956&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

Reputation: 0
• Posts: 30
• Joined: 16-January 13

# Hello, i need help finishing my code

Posted 16 January 2013 - 10:02 AM

Hello i cant finish my code. What i basically need to do is (this is a rough transaltion to english)
Is make a A[4][7] matrix , then get the columns 4,5,6,7 displayed on the screen and then i need to somehow make the colums add up the numbers in the to a sum. For example the coulm for may have numbers 53,213,421,232 so my programm needs to add them all up 53+213+421+232=917, and like that with EACH of the columns.
I have manuaged to somehow make the matrix , get each of the columns displayed on the screen but i have no clue how to make it add them up to a sum.

This is what i manauged to make.
Also i was hinted that i should add
``` int nTotal = 0;
```
and after that put
``` (nTotal += maatriks[i][3]);
```
in a loop somewhere? i didnt understand any of that.....

```#include <stdio.h>
#include <time.h>
#include <stdlib.h>

#define RIDU 4
#define VEERGE 7
#define MAX 150
#define MIN 10

int main (void)

{

int maatriks [RIDU] [VEERGE];
int i,j;

srand(time(NULL));

for(i=0; i<RIDU; i++)

{
for(j=0; j<VEERGE; j++)
{

maatriks[i][j]=rand()%(MAX-MIN)+MIN;
}
}

printf("Generated matrix is :\n\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{
printf("%4d", maatriks[i][j]);
}
printf("\n\n");
}

printf("========================================\n");
printf("Colums from the third to the right\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{

if (j>2)  printf("%4d", maatriks[i][j]);
}
printf("\n");
}
printf("========================================\n");

for(i=0; i<RIDU; i++)
{

}

printf("Fourth column and its sum\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{
(nTotal += maatriks[i][3]);
if (j<1)  printf("%4d", maatriks[i][3]);
}
printf("\n");
}
printf("----------------------------------------\n");

printf("Fourth column and its sum\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{
if (j<1)  printf("%4d", maatriks[i][4]);
}
printf("\n");
}
printf("----------------------------------------\n");

printf("Fifth column and its sum\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{
if (j<1)  printf("%4d", maatriks[i][5]);
}
printf("\n");
}
printf("----------------------------------------\n");

printf("sixth column and its sum\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{

if (j<1)  printf("%4d", maatriks[i][6]);
}
printf("\n");
}
printf("----------------------------------------\n");

scanf("%d");

return 0;
}

```

Is This A Good Question/Topic? 0

## Replies To: Hello, i need help finishing my code

### #2 jimblumberg

Reputation: 5447
• Posts: 16,971
• Joined: 25-December 09

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:13 AM

Also posted here. The code seems to be an almost direct copy of this, is that your code?

Jim

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:16 AM

yup, searched a new forum, cuz the person that helped me there seemed to go offline, so i found a new forum, while still checking on on that one. For more help/ideas, etc..

How on earth does information go around so fast on 2 diffrent forums O.o

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:23 AM

double post because i cant find any butten to edit my last one.

And since nobody was really able to help me on that forum, i googled this one, hoping to get help from someone here to finish the code.... i dont have any idea how i can sum them up one by one. So can you help me with this?

### #5 modi123_1

• Suitor #2

Reputation: 13954
• Posts: 55,699
• Joined: 12-June 08

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:25 AM

To be clear you just want us to write the code for you?

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:29 AM

I gave u the code i have manuaged to make, and i was also hinted that little bit of code.... but i dont understand it.

Write, explane, teach, show, etc, which ever, anything so i can finish it! I need to finish this code by any way possible but i have no clue on how to make them sum it up

### #7 modi123_1

• Suitor #2

Reputation: 13954
• Posts: 55,699
• Joined: 12-June 08

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:31 AM

Well just use two for loops. It's a basic solution.

### #8 jimblumberg

Reputation: 5447
• Posts: 16,971
• Joined: 25-December 09

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:34 AM

Quote

I gave u the code i have manuaged to make,

More like you gave us the code you managed to find somewhere on the internet.

Quote

Write, explane, teach, show, etc, which ever, anything so i can finish it!

We will not write the solution for you, you need to ask specific questions about your code.

What exactly don't you understand?

Jim

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:37 AM

i don't understand what that means....

i didnt find it off the internet, read the username of the place U SOW and the username here, read the CREATION time of both users, both are mine, both codes are made by me. Even look at the emails registrated by both users, both are exactly the same their both my codes!

And that is a specific question, i dont understand how to SUM them up.

### #10 modi123_1

• Suitor #2

Reputation: 13954
• Posts: 55,699
• Joined: 12-June 08

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:38 AM

Quote

i don't understand what that means....

What are you referring to? If it's jim's post then it means we are not going to do your homework for you.

edit: if you are unsure why we are not a homework service feel free to shoot me a pm.

This post has been edited by modi123_1: 16 January 2013 - 10:40 AM

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:42 AM

K, more specific where do i put (nTotal += maatriks[i][3]); to make it sum up the 4th column. I know i have to put it in a loop? But i dont understand loops so much. the i,j then the signs <,> confuse me

and i was refering to yours, what two loops? where, how?

And how is asking ONE part of it doing my homework for me?

### #12 modi123_1

• Suitor #2

Reputation: 13954
• Posts: 55,699
• Joined: 12-June 08

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 10:50 AM

Ha.. I read your other forum post.. and smelled as much here. Just consider it a friendly warning.

As for for-loops.. well reread your section and possibly check out the tutorial.
http://www.dreaminco...ditional-loops/

So you have a loop control variable.. you tell it what value to start at, what condition it stops counting, and the direction/amount it increments. A pretty straight forward structure. You can next those inside each other and have one count up through the row numbers and have the other count the columns in that specific row.

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 11:28 AM

I watched a short tutorail on loops and after that this short tutorial

i understand now what this means (nTotal += maatriks[i][3]);
As in that piece of code in the loop
though it still feels like it is missing a line or 2 of code... aside form me not knowing how to put it on screen....

```int nTotal = 0;

{

}

printf("Fourth column and its sum\n");

for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{

if (j<1)  printf("%4d", maatriks[i][3]);
nTotal += maatriks[i][3]);
}
printf("\n");
}

```

Reputation: 0
• Posts: 30
• Joined: 16-January 13

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 12:05 PM

so i made it, so it shows me the result on the screen.... and i got total crap.... just a huge number thats nowhere near suming anyhthing up...

### #15 modi123_1

• Suitor #2

Reputation: 13954
• Posts: 55,699
• Joined: 12-June 08

## Re: Hello, i need help finishing my code

Posted 16 January 2013 - 12:08 PM

Perhaps showing us what the input was and the output may help us better to help you.