User Profile

Collapse

Profile Sidebar

Collapse
logicode
logicode
Last Activity: Apr 12 '07, 12:24 AM
Joined: Apr 5 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • logicode
    replied to Program HELP with Sign Function
    in C
    Try making the base 0 and it returns a garbage value for the sign function.
    See more | Go to post

    Leave a comment:


  • logicode
    started a topic Program HELP with Sign Function
    in C

    Program HELP with Sign Function

    I have a program that works fine but when I put in a zero the sign is supposed to return zero but doesn't
    Code:
     
    
    #include <iostream.h>
    #include <stdlib.h>
    
    
    ////////////////////////////////////////////////
    //Power Function
    
     int power(int,int);
    int power(int base,int exp)
    {
      int sum=1;
      for (int i = 0; i < exp; i++)
    {
        sum=
    ...
    See more | Go to post

  • logicode
    replied to Loop Question
    in C
    Can someone give me an answer please?
    See more | Go to post

    Leave a comment:


  • logicode
    started a topic Loop Question
    in C

    Loop Question

    I need a loop that can be put in 3 instances. I am not sure which loop I can find and I dont want to use a switch statement so can you help? I Already know the code just the loop for it.
    Basically I want to

    if (blabla)
    { then do this};
    if (blabla2)
    { then do this};
    if (blabla3)
    {then do this};
    See more | Go to post

  • logicode
    replied to the power function
    in C
    Code:
      for (int i = 0; i < exp; i++);
    {
        sum= base*sum;
    }
          return sum;
    
    }
    ok I should have seen that but in this one All I get in return is the origional value
    See more | Go to post
    Last edited by sicarie; Apr 5 '07, 01:38 PM. Reason: Full code removed per FAQ, and please use [code] and [/code] tags.

    Leave a comment:


  • logicode
    replied to the power function
    in C
    Code:
      for (int i = 0; i < exp; i++);
      {
        sum= base*sum;
         return sum;
       }
    See more | Go to post
    Last edited by sicarie; Apr 5 '07, 04:19 AM. Reason: Please use [code] and [/code] tags around your code.

    Leave a comment:


  • logicode
    replied to the power function
    in C
    can I send in my code so you can see it
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    ahh ok I dont know why but that works so here is the thing
    I input 5
    then input 2
    it says that the answer is 5
    cout<<sum...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    I get one error when I try to run it says parse error and points to
    for (int i = 0; i < exp; i++; )...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    hmmm like

    for( i=0; i<exponent; i++; sum=1 )
    {
    sum= base* sum
    }

    then base which is the base will be multiplyed by the sum which os one but when the loop comes back around wont the sum be 1 again? This doesnt make sense to me.
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    ok I am seeing the working but I still dont get how you will declare the sum = 1
    And in the loop the sum will have a new value but when the loop, loops, I beleive the sum will become 1 again....
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    I dont quite get what you are trying to ask me...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    I passed in base first and being base...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    well in your example n should start out with sum =1 but doesnt the sum = 1 restart the sum = sum * base when it loops?...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    x^3 because x^2 * x = x^3...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    well you want the base * base so would sum = base * base work I dont think so because then I think the sum with then need to be multiplyed by the base? Am I making things more complex?...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    ok...i'm on the edge I know it =] just not quit there...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    x^5 and using that method "variable += 1"confuses the crap out of me I rather just use the straight out one....
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    the loop ends when the counter becomes less then the exponent. I was thinking that base=base*base but I knew that wouldnt work so I need a third variable I think to store the original base in and then multiply it by the base untill the loop ends...
    See more | Go to post

    Leave a comment:


  • logicode
    replied to the power function
    in C
    i"m stuck..... Can you throw me a hint...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...