Search:

Type: Posts; User: Watabou

Search: Search took 0.01 seconds.

  1. Replies
    7
    Views
    1,482

    I guess it doesn't work like this? void...

    I guess it doesn't work like this?


    void add(struct node *first, struct node *second) {


    int sum = 0;
    struct node *addition;

    while ((first != NULL && second != NULL)) {
  2. Replies
    7
    Views
    1,482

    Okay so I have while(first!=NULL &&...

    Okay so I have


    while(first!=NULL && second!=NULL) and it works fine now.


    I still don't get it. Can you explain it in simple terms?


    And can you also check if I'm doing the algorithm...
  3. Replies
    7
    Views
    1,482

    I thought I already was. Like I said, when I...

    I thought I already was.

    Like I said, when I enter 12345, and the printf evalutes, it returns 4 because temp->prev->data = 4. So I know I'm doing it backwards.

    Besides, that's not my problem....
  4. Replies
    7
    Views
    1,482

    Adding linked list problem

    Hi guys. I'm trying to learn how to add two long integers in a linked list.

    So 1->2->3->NULL and 4->5->6->NULL should give me 5->7->9->NULL

    I know how to approach the problem but the problem...
  5. Replies
    15
    Views
    2,495

    Well in my main function, I have a while loop: ...

    Well in my main function, I have a while loop:


    while (1) {

    printf("Enter a command: ");

    fgets(command, sizeof(command), stdin);
    command[strlen(command) - 1] = '\0';
  6. Replies
    15
    Views
    2,495

    Yeah it's this: int sumDiv(int number) { ...

    Yeah it's this:



    int sumDiv(int number) {

    int i;
    int sum = 0;
    for (i = 1; i <= number; i++) {
    if(number % i == 0)
  7. Replies
    15
    Views
    2,495

    Hmm okay so this is what I think you're saying: ...

    Hmm okay so this is what I think you're saying:


    void findAmicable(int number) {
    int sum1 = sumDiv(number);

    if (sumDiv(sum1) == number) {
    printf("%d %d\n", number, sum1);
    }
  8. Replies
    15
    Views
    2,495

    Okay I'm a bit confused now. So first I get...

    Okay I'm a bit confused now.

    So first I get all the factors of n and sum it. And that's sum1.

    Then I make a loop to find the second number to go with it? How would I do that? Won't that be a...
  9. Replies
    15
    Views
    2,495

    Yeah you're right. I was actually planning on...

    Yeah you're right. I was actually planning on doing that later. It's what I used for prime and perfect numbers. I wanted to see what the program was actually doing in the debugger so I thought it...
  10. Replies
    15
    Views
    2,495

    Oh whoops, maybe that's the problem. I'll see if...

    Oh whoops, maybe that's the problem. I'll see if that fixes it.

    Oh and it's kinda hard to explain amicable numbers. One example is 220 and 284. They are amicable numbers since the factors of 220...
  11. Replies
    15
    Views
    2,495

    Why isn't this working?

    Hi guys, I wrote up a long program that pretty much works. What it does is when the user enters a string like 4,100 the program prints out all the prime,perfect and amicable pairs in that range.
    ...
  12. Replies
    3
    Views
    1,286

    Oh thanks. Yeah I should have read the FAQ. Sorry...

    Oh thanks. Yeah I should have read the FAQ. Sorry about that.
  13. Replies
    3
    Views
    1,286

    User input being a number?

    Hi guys,
    I have a technical question. How do I see if the user's input is a number?

    So for example, when they type in 6,4 how can I get both 6 and 4 to store it in two variables?
    I tried to...
  14. Replies
    2
    Views
    967

    User input being a number?

    Hi guys,
    I have a technical question. How do I see if the user's input is a number?

    So for example, when they type in 6,4 how can I get both 6 and 4 to store it in two variables?
    I tried to...
  15. Replies
    6
    Views
    1,904

    Okay so is this what you mean because I'm still...

    Okay so is this what you mean because I'm still not there yet.




    #include <stdio.h>
    #include <string.h>

    #define N_ROWS 6
  16. Replies
    6
    Views
    1,904

    Oh sorry about that. Yeah I do have global...

    Oh sorry about that.

    Yeah I do have global variables but I guess I will move them inside main.


    Okay so you mean I should include each of them in the printf statements in each of the cases or...
  17. Replies
    6
    Views
    1,904

    Help printing 4x4 grid

    Hi guys, I'm having some trouble printing out a 4x4 grid. A 1x1 grid is supposed to look like this:



    +----+
    | |
    | |
    | |
    +----+
  18. I tried that but it doesn't seem to work. Maybe...

    I tried that but it doesn't seem to work. Maybe I'm using a wrong printf conversion?

    If I wanted to test that out, would I use

    printf("%s", board);
  19. Okay but I don't get how I would store it in the...

    Okay but I don't get how I would store it in the array.

    I mean, I get that if row is 0 or 3 in this case, it would output the first and last rows and the else statement is for the middle. But how...
  20. So by first/ last rows you mean +---+ ...

    So by first/ last rows you mean



    +---+


    +---+
  21. Hmm I don't really understand that... Also...

    Hmm I don't really understand that...

    Also what are the ? and : for?
  22. Printing an 4x4 grid and storing it in an array?

    Hi guys, I'm new here and I'm fairly new to C.

    This maybe simple to most of you guys but I'm extremely frustrated because I don't know what to do with it at all.

    The problem is, I want to...
Results 1 to 22 of 22