Okay, a put a printf in the nested for loop, but instead of printing the 5x5 matrix, it just prints all 25 numbers right in a row. How do I fix this?
#include <stdio.h>
#include <stdlib.h>
...
Type: Posts; User: DCMann2
Okay, a put a printf in the nested for loop, but instead of printing the 5x5 matrix, it just prints all 25 numbers right in a row. How do I fix this?
#include <stdio.h>
#include <stdlib.h>
...
#include <stdio.h>
#include <stdlib.h>
#define DIM 5
int main()
{
int mat[DIM][DIM] = {0}, row, col, rowSum, colSum;
printf("Enter 25 numbers: ");
No, I'd enter them with spaces between them, like 1 2 3 4 5 etc.
I wanted it to print the whole matrix, though, not just a single element. I tried doing printf("%d", mat[row][col]), but that didn't work...it gave me that big number I was telling you about earlier....
I know it's not what I want, but can you explain why the matrix isn't working properly? I tried doing a printf of the matrix, but all it gives me is one big number that doesn't contain a single...
Alright, I've done some more work on this since I last posted, but it's not working right. I'm pretty sure my rowSum and colSum functions are wrong, but at this point I'm mostly concerned about...
That's great, but I still don't know how to actually allow the user to enter the values they want. How do I do that? I've read the chapter in my book about arrays a thousand times and I still can't...
Use the same code? How would I do that? If I can get the row adding part sorted out, I could figure out the column part without too much difficulty.
I'm still having trouble with entering the...
I understand how the code works, but now that I have that code, how do I allow the user to enter the values of the array so I can add up the rows and columns?
#include <stdio.h>
#include...
Is it possible to use a single dimensional array? It seems that it might be easier to use a one dimensional array because it's easier to add the rows that way, but would it possible to add up the...
Hi all, I'm having trouble working with an array, and I was wondering if anyone could explain it to me. What I want to do is have a 5x5 array, entered one row at a time, that will add each row and...
I initialized maximum to 0, but it still prints the maximum number as 0 because the statement
if (current > maximum)
current = maximum;
Will always be true, so current is always...
As far as I could tell, it set the maximum number as the current number, but the trouble I'm having is figuring out how to hold that number as the max until the current number is bigger, then just...
That's just it, I'm not exactly sure how to tell the program that the current number is the maximum until the current number is bigger than the maximum. I've changed the code a little bit, but I...
Hey guys, I'm still having a bit of trouble getting the loop to work properly. Every time the program executes and exits the loop, it always prints the maximum as 0.00000. Can anyone explain why this...
So what you're saying is I should set up a while loop with if statements? Like, I could have two variables named num1 and num2, and in the loop have an if statement saying if num1 >= num2, num1 =...
Hi all,
I'm having a bit of a brain fart with this loop problem, and I was wondering if I could get a little help from you guys.
I'm supposed to write a program that finds the largest in a...
I ended up getting it to work on my own, but I'll definitely save this code here for future reference. Thanks a lot for your help! :D
Alright, I did some work to my code, but the section where the user is supposed to enter the coordinates is still giving me problems. Here's what I have so far:
void fillBoard(bool...
That would make that cell alive or dead, right? The problem I'm running into now is how I can allow the user to specify which cell he or she wants alive or dead. For example, if I want cell 1,1 to be...
This is the part of the code that I'm having the most trouble with. It doesn't compile in its current form, but if someone could give me some pointers in the right direction, I can try to get it...
Hi everyone, I need some help with some code modification for a game. It's based off of John Conway's Game of Life, and some parts of the code are proving tricky. The code I have now compiles and...
Both. Here's the code I have now:
#include <stdio.h>
#include <stdlib.h>
#define ARRAY_SIZE 30
int main(int argc, char *argv[])
{
Alright, I did that, but it's still giving me a huge number for some reason.
I did the math myself, and sum is supposed to be equal to 2408, so the average is supposed to be about 80. When I run...
Okay, I did a bit more work, and it's displaying all the names and scores right, but I'm having problems figuring out how to keep a total of all the scores so I can use them to find the average and...