Before the loop.
int nTotal = 0;
Inside the loop
nTotal += maatriks[i][2]);
Printable View
Before the loop.
int nTotal = 0;
Inside the loop
nTotal += maatriks[i][2]);
question what exactly does "n total" mean and do? never heard of anything like that before
EDIT, i tryed to add what u said in... but for some reason now when i activate the program, everything broke down int o massive ENDLESS ammount of numbers? so i dont know what to do agian :(
well alteast i THINK i did it as u said....
question what exactly does "n total" mean and do? never heard of anything like that before :( i think i am doing something wrong
i put the int nTotal = 0; to the top where i declare all my other stuff like int i,j;
and then nTotal += maatriks[i][3]); inside one of the loops? wow i just relized it is probably hard for you to understand half of my code because a lot of the words are written in first language
Which part of there is no space between n and total was unclear?
ou sorry, the first sentance of my second post somehow came along with my last one,
i corrected the space but i still coulnt get it work, i think i am putting the nTotal += maatriks[i][3]); in the wrong place maybe? Where exactly in the code am i suppose to put it, the endless numbers stoped with the N fixing, but now simply nothing happens when i add that part? i must be doing something really wrong.
i think i put it in the loop.....(if i understand correctly what loop means..... it is an english word that i have never heard before, my programming is taught to me in my own language so i am trying really hard to get to the right place)
lol i wish, i can ask but they wont answer, as i said "i have to do it myself by any way i can find out how or feagure out how, he simply wont tell me how, so he isnt an option to find out form"
also a LOT of the code is right now overlaping itself cuz i leave in every single thing i learned right now and once i get something done i delete out the crap. If anything is ununderstandebe because estonian i can translate most
#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;
int nTotal = 0;
srand(time(NULL));
for(i=0; i<RIDU; i++)
{
for(j=0; j<VEERGE; j++)
{
maatriks[i][j]=rand()%(MAX-MIN)+MIN;
}
}
printf("Genereeritud matrix on:\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("Kolmandast tulbast paremale jäävad tulbad\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");
printf("neljas tulp ja selle arvude summad\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("viies tulp ja selle arvude summad\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("kuues tulp ja selle arvude summad\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("kuues tulp ja selle arvude summad\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");
printf("\n\n\n\n");
printf("Neljas tulp ja selle arvude summad\n");
j = 3;
for(i=0; i<RIDU; i++)
{
printf(" %4d", maatriks[i][j]);
}
printf("\n");
return 0;
}
i would use that speical box you guys use to put the code in, but i dont know how u guys get it
You've been told several times you don't need a loop that increments the column variable. You've also been told several times that to access the third column, the index should be 2, not 3.
This is what your summing loop should look like.
Code:for(i=0; i<RIDU; i++)
{
nTotal += maatriks[i][2];
}
I dont need the third colum ( i need 4,5,6,7) i think i transalted that question in the start a bit wrong.
And about the loop i dont really understand what that word means so i mix and matched things...
so how do u get it on scr