i have a question?

This is a discussion on i have a question? within the C Programming forums, part of the General Programming Boards category; in pointers can we use for loop in the function or we should use the recursion with it...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    Talking i have a question?

    in pointers
    can we use for loop in the function or
    we should use the recursion with it
    show me the meaning

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    You can use for loops to increment/decrement pointers and such, for arrays or whatever. What are you asking?
    Away.

  3. #3
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    heh, what do u mean????

    so far, I can give you some hints, where you can find something about pointers:

    www.cprogramming.com (the tutorials)

    can u help me with pointers?plzzzzzzzz

    and search the board

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    i mean

    i find the answer
    i was mean that
    if we writing a function
    in pointers
    can we use for loop inside
    the function or we should use only (if -else)
    show me the meaning

  5. #5
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    yeah, why not????

    I don't know, what you wanna do, so you have to decide, whether it's better or worse for your prog....

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    i do this program but i cant find the error

    Write a function addElement that takes as parameters: a pointer to a sorted array of integer numbers, array size (number of elements stored in the array), and the number to be inserted in the array. The function should insert the element in the proper position to keep the list sorted. Use pointer operations to access the elements of the array. The function prototype is

    void addElement(intt *array, int *sizeptr, int num);



    #include <stdio.h>
    #define size 10
    void addelement(int*,int *,int );
    int main()
    {
    int i,array[10],s,num;

    printf ("enter the size\n");
    scanf("%d",&s);
    printf("enter the array:\n");
    for(i=0;i<=s;i++)
    scanf("%d",&array[s]);
    printf("add a number to the array\n");
    addelement(array, &s, num);


    return 0;
    }
    void addelement(int*array,int *sizeptr,int num)
    {
    int i;
    for(i=0; i >=sizeptr ; i++)
    printf ("add number");

    printf("%d\n%d ",array[size],num);

    }
    }
    show me the meaning

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    Exclamation can u find the error

    i do this program but i cant find the error
    Write a function addElement that takes as parameters: a pointer to a sorted array of integer numbers, array size (number of elements stored in the array), and the number to be inserted in the array. The function should insert the element in the proper position to keep the list sorted. Use pointer operations to access the elements of the array. The function prototype is

    void addElement(intt *array, int *sizeptr, int num);



    #include <stdio.h>
    #define size 10
    void addelement(int*,int *,int );
    int main()
    {
    int i,array[10],s,num;

    printf ("enter the size\n");
    scanf("%d",&s);
    printf("enter the array:\n");
    for(i=0;i<=s;i++)
    scanf("%d",&array[s]);
    printf("add a number to the array\n");
    addelement(array, &s, num);


    return 0;
    }
    void addelement(int*array,int *sizeptr,int num)
    {
    int i;
    for(i=0; i >=sizeptr ; i++)
    printf ("add number");

    printf("%d\n%d ",array[size],num);

    }
    }

    thanx
    show me the meaning

  8. #8
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    It think, this is correct now:

    Code:
    #include <stdio.h>
    #define size 10
    void addelement(int*,int *,int );
    int main()
    {
    int i,array[10],s,num;
    
    printf ("enter the size\n");
    scanf("%d",&s);
    printf("enter the array:\n");
    for(i=0;i<=s;i++)
    scanf("%d",&array[s]);
    printf("add a number to the array\n");
    addelement(array, &s, num);
    
    
    return 0;
    }
    void addelement(int*array,int *sizeptr,int num)
    {
    int i;
    for(i=0; i >=*sizeptr ; i++)
    printf ("add number");
    
    printf("%d\n%d ",array[size],num);
    
    }
    heh, solved ya problem again
    I haven't had compiled it.... I found 2 mistakes.
    [edit]
    Plz check it, whether it compiles and runs corrently and whether it does, what you want it to do for you
    [/edit]
    Last edited by codingmaster; 07-12-2003 at 01:23 PM.

  9. #9
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    still there is some thing missin

    the program run
    but
    in the end
    it doesnt
    type the number i add
    it gives
    the position
    of num
    show me the meaning

  10. #10
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157

    Re: still there is some thing missin

    Originally posted by itcs
    the program run
    but
    in the end
    it doesnt
    type the number i add
    it gives
    the position
    of num


    Burma Shave!


    Sorry, couldn't resist
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  11. #11
    Registered User
    Join Date
    Jul 2003
    Posts
    14
    still not run
    as i want
    can u
    write
    all the
    program
    plz
    may be i didnt understand u
    show me the meaning

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by itcs
    still not run
    as i want
    can u
    write
    all the
    program
    plz
    may be i didnt understand u
    Most of it has been written for you already. try piecing it all together, and then askng specific questions when you need help.

    [edit]
    Doh, beat!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    thanx any way

    u help me sooooooooooo
    much all of u
    I promise to post it on tuseday
    because i think
    i can answer it now
    see u then
    thank salem &mastercode
    show me the meaning

  14. #14
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    ????? mastercode ??????



    I'm codingmaster

  15. #15
    Registered User
    Join Date
    Jul 2003
    Posts
    14

    Talking sorry

    i didnt mean 2 heart u r feeling
    coodingmaster

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21