Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.17 seconds.

  1. Replies
    6
    Views
    122

    Try it with only one % and one / inside the loop....

    Try it with only one % and one / inside the loop.

    Maybe just this to begin with.


    while ( number > 0 ) {
    printf("Number=%d\n", number);
    number = number / 10;
    }
  2. Thread: File Data Saving

    by Salem
    Replies
    4
    Views
    94

    > if (theta[10000]=omega*time[10000]) 1. These...

    > if (theta[10000]=omega*time[10000])
    1. These array elements don't exist.
    The last subscript in an array of 10000 elements is 9999 (it's always N-1 for an array[N])

    Line38 onwards made no...
  3. Replies
    6
    Views
    122

    Do you know about while loops? Now would be a...

    Do you know about while loops?

    Now would be a good time to find out.

    As in, while you have some number > 0, you do your % and / thing.
  4. Well you pretty much have to throw it away and...

    Well you pretty much have to throw it away and read MSDN on how to use the serial port using the Win32 API.

    You can save all the code which deals with data once it's in memory.

    But all that...
  5. Replies
    6
    Views
    116

    > but I am surprised that you did not use the...

    > but I am surprised that you did not use the else if statement
    That would imply that you have more than true/false at some level.



    if ( n == 1 ) {
    } else if ( n == 2 ) {
    } else {
    }
  6. Replies
    8
    Views
    222

    Moved to the jobs board.

    Moved to the jobs board.
  7. Replies
    6
    Views
    116

    Like so - for you to finish off... if ( E1 )...

    Like so - for you to finish off...


    if ( E1 ) {
    if ( E2 ) {
    S2;
    } else {
    S21;
    }
    } else {
  8. Replies
    6
    Views
    116

    Maybe if you gave each expression in your diagram...

    Maybe if you gave each expression in your diagram a different name, it would help when you saw the code.
  9. sync(2): commit buffer cache to disk - Linux man...

    sync(2): commit buffer cache to disk - Linux man page - code
    sync(1): flush file system buffers - Linux man page - command line

    That the bogus files disappear on reboot could just be down to an...
  10. Replies
    4
    Views
    131

    > But does any function also have life time and...

    > But does any function also have life time and scope ?
    Their scope depends on whether you use the word 'static' or not.
    Their lifetime is the life of the program - excluding the case of functions...
  11. Replies
    6
    Views
    133

    It looks like you tried to compile without your...

    It looks like you tried to compile without your main.c



    $ head -20 foo.c main.c
    ==> foo.c <==
    #include<stdio.h>

    extern int x;
  12. It's returning int, so it's 20.

    It's returning int, so it's 20.
  13. Maybe this instead. return *p;

    Maybe this instead.

    return *p;
  14. Replies
    43
    Views
    745

    You start with this. int main() { int...

    You start with this.


    int main() {
    int lotto[49] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
    13, 14,15, 16, 17, 18, 19, 20, 21,22, 23, 24, 25,
    26,...
  15. > Line number 10 calls function next , but how...

    > Line number 10 calls function next , but how come value getting changed in bags arrary.
    Because
    a) you returned a pointer
    b) you dereferenced that pointer
    c) you have an assignment.

    Line 10...
  16. Replies
    1
    Views
    113

    Better variable names to start with. This...

    Better variable names to start with.

    This prints information about the structure of the shape you want


    for ( row = 0, items_on_row = 4 ; row < 3 ; row++, items_on_row-- ) {
    printf("Row %d...
  17. Replies
    43
    Views
    745

    First, you said > I want to create a program...

    First, you said
    > I want to create a program which generates 6 numbers from a range of 1 to 49.

    > Ok,but how is that going to help me input 6 numbers and check if the input I gave is right or...
  18. Seriously, compile with warnings and fix them...

    Seriously, compile with warnings and fix them before running code.


    $ gcc -Wall foo.c
    foo.c: In function ‘main’:
    foo.c:63:15: warning: format ‘%d’ expects argument of type ‘int *’, but argument...
  19. Replies
    43
    Views
    745

    Well next, let's introduce you to the idea of a...

    Well next, let's introduce you to the idea of a shuffle.



    // pick two random lotto number positions
    int p1 = rand() % 49;
    int p2 = rand() % 49;
    // now swap them over
    int temp = lotto[p1];...
  20. Replies
    5
    Views
    213

    Having a function called 'get' which returns...

    Having a function called 'get' which returns nothing is just weird.

    And just pushing the infinite recursion out of main doesn't really make much progress.



    #include <stdlib.h>

    void...
  21. Replies
    43
    Views
    745

    > printf("%d",lotto[i]); So change the format...

    > printf("%d",lotto[i]);
    So change the format string

    printf("%d ",lotto[i]);
    or
    printf("%d, ",lotto[i]);
    or
    printf("%d\n",lotto[i]);
    or
    printf("= %d\n",lotto[i]);
  22. Replies
    4
    Views
    191

    > combination(a,start+1, 3); Perhaps...

    > combination(a,start+1, 3);
    Perhaps
    combination(a,start+1, com-1);

    The whole point of a recursive function is that you call yourself with a simpler version of the problem.
    Which in this case,...
  23. Replies
    43
    Views
    745

    > The code is indeed complicated but since this...

    > The code is indeed complicated but since this is the only thing I found...
    So it looks like wolly isn't interested in learning after all.
    Just another drive-by looking for easy google answers.
    ...
  24. Replies
    43
    Views
    745

    int numbers[49]; for ( int = 0 ; i < 49 ; i++ )...

    int numbers[49];
    for ( int = 0 ; i < 49 ; i++ ) numbers[i] = i+1;


    vs this, which wastes element 0 of the array.


    int numbers[50];
    for ( int = 1 ; i <= 49 ; i++ ) numbers[i] = i;
  25. Replies
    43
    Views
    745

    Right, first issue is that arrays start at...

    Right, first issue is that arrays start at subscript 0.

    So either make your array 50 elements long, or your loop
    for ( i = 0 ; i < 49 ; i++ )


    Then I asked you to print the array.
    Which...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4