CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2012
    Posts
    4

    Exclamation i'm stuck HELP, thanks

    i want to write a function that can add only -ve numbers from a list of integers. i can declare a function that can add the negative numbers, my problem is how do i get the -ve numbers from a string of both +ve and -ve numbers

    int SumOfNumbers(int a, int b){
    int result;
    result = a+b;
    return (result);
    }

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: i'm stuck HELP, thanks

    Please use real words. It took a while to figure out what a -ve number is.

    I don't see a string in your code.

  3. #3
    Join Date
    Sep 2012
    Posts
    4

    Re: i'm stuck HELP, thanks

    this where the problem is, i want to declare a function that captures both negative and positive numbers but adds only the negative numbers in from the input

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: i'm stuck HELP, thanks

    How about using an array or vector of ints and just testing for < 0.

  5. #5
    Join Date
    Sep 2012
    Posts
    4

    Re: i'm stuck HELP, thanks

    much help THANKS, I'll notify you when i come up with something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured