Thread: Problem With Pow Function, Help?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    28
    Hey,

    Thanks for responding... I tried your suggestions, both the int in the main() and making the pow a double, but neither seem to be working. I still get the same error.

    Any ideas?

    Also, what do you mean, the difference between '1' and 1?


    Thanks for your help!


    Here's the code:
    Code:
              #include <iostream>
              #include <iomanip>
              #include <cmath>
    
              using namespace std;
    
              int main ()
                 {
                 int count = 0, bin, sum;
                 char line[32] ;
    
                 cin >> noskipws >> line[0] ;
                 while ( line[count] != '\n' )
                    {
                    count ++ ;
                    cin >> line[count] ;
                    }
    
                 sum = 0;
    
                 for ( bin = count - 1; bin >= 0; bin -- )
                    {
                    sum = sum + (line[bin] * pow(2.0,bin));
                    }
    
                 cout << sum;
                 cout << endl ;
                 }
    Last edited by verd; 02-26-2006 at 07:14 PM. Reason: Forgot Code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Replies: 3
    Last Post: 10-28-2009, 09:25 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM