AFellowUser's Profile User Rating:

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
13 (0.02 per day)
Joined:
28-September 12
Profile Views:
165
Last Active:
Dec 13 2012 03:12 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
AFellowUser has not set their status

1. In Topic: Filling specific elements in an array

Posted 12 Dec 2012

ipushmycar, on 12 December 2012 - 12:55 PM, said:

AFellowUser, on 12 December 2012 - 02:50 PM, said:

Sorry for the double post, but I solved the problem. Thanks for the help! This code seemed to do the trick:

```    while (i < ROW && j < COL)
{
array1[i][j] = 0;
i++;
j++;
}
```

That doesn't set the diagonals.

Really? It set every fifth element to 0, is that not where every diagonal element occurs? Here's my full source:
```#include <stdio.h>
#define ROW 5
#define COL 5
#define SIZE 10
main()
{
int array1[ROW][COL] = { {5, 5, 5, 5, 5},
{5, 5, 5, 5, 5},
{5, 5, 5, 5, 5},
{5, 5, 5, 5, 5},
{5, 5, 5, 5, 5}
};
int i = 0, j = 0;

while (i < ROW && j < COL)
{
array1[i][j] = 0;
i++;
j++;
}
```
2. In Topic: Filling specific elements in an array

Posted 12 Dec 2012

Sorry for the double post, but I solved the problem. Thanks for the help! This code seemed to do the trick:

```    while (i < ROW && j < COL)
{
array1[i][j] = 0;
i++;
j++;
}
```
3. In Topic: Filling specific elements in an array

Posted 12 Dec 2012

ipushmycar, on 12 December 2012 - 12:21 PM, said:

Just an FYI
```int anArray[ROW][COL] = { 5 };

```

Would initialize the array to 5.

You are on the right idea with the for-loop and the array[0][0].
The diagonal is when i = j. So you could write a if-statement to test when i=j and when it does set array[i][j] to 0.

So I would do something like this? :

```if (i == j)
{
array1[i][j] = 0;
}
```

That seems to set all elements to 0, also I didn't realise I had initially hardcoded in the original code, so ignore that bit.
4. In Topic: Lives deduction not working

Posted 25 Nov 2012

tlhIn`toq, on 25 November 2012 - 12:45 PM, said:

Its not really "for whatever reason". Its because you told it to that.

Line 14 - Deduct a life if C is greater than 0
Line 6 & 10 - Regardless of the outcome of the if check, increase the value of c - HELLO! - So no matter what c will be greater than 0

Oh, I should have mentioned it in the comments but 'count++' is not related to lives deduction, that's just a different part of the program which I didn't leave out.
5. In Topic: Math code not working as it should

Posted 29 Oct 2012

Oler1s, on 29 October 2012 - 04:19 PM, said:

Quote

I fooled around with the code there but nothing changed/errors were thrown. Is a switch just not useable in this case or am I just doing it wrong?
You get compilation errors when you write something syntactically incorrect.

The problem isn't syntax. The problem is that you wrote syntactically correct nonsense. It makes no sense whatsoever.

So here's a question for you.

What is the purpose of the switch block? Why do you have that there?

Well, that wasn't the full program I intended to write. I intend to write a simple maths program in which you have a certain amount of lives, then you do sums, and if you get it wrong then you lose a life, etc. Obviously the sums will be more complicated, this is just a proof of concept at the moment.

The purpose of the switch was to actually do the math, for example if the number 3 slot in the symbol array was chosen, then it would hopefully refer to the multiplication case in the switch and then figure out the answer, if you get me.

Member Title:
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

E-mail:
Private

Friends

AFellowUser hasn't added any friends yet.