Largest palindrome that can be made from a product of 2 3-digit numbers (Project Euler 4)
Speeding things up
There are several things you could do to speed things up:

Instead of looping from 100..999, go from 999..100 instead.  That way, if you find a palindrome, you can break from the j loop because any lower values of j will not beat the one you just found.
Once you loop backwards, you can also check i*j versus the best answer you've found so far.  If i*j &lt;= best, you can break from the j loop.
You don't have to use log10 to find the number of digits.  Since you are already converting the number to a string, just use num_stringstream.length().
The j loop can start at i instead of 999, because any j higher than i will already have been tested.

Cleaning things up
It would make your program look a lot more readable if you moved all of the palindrome checking logic to its own function.
This line here is very hard to read:

num_to_test&gt;ans?ans=num_to_test:ans=ans;


Putting it all together
Here is what I think your code should look like.  I removed the cin &lt;&lt; quit part because I wanted to time the program without requiring user input.
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;iostream&gt;

bool is_palindrome(int num)
{
    ostringstream convert;
    convert &lt;&lt; num;
    string num_stringstream = convert.str();
    int num_of_digits = num_stringstream.length();
    for (int i=0; i &lt; num_of_digits; i++)
    {
        if (num_stringstream[i] != num_stringstream[num_of_digits-i-1])
            return false;
    }
    return true;
}

int main(void)
{
    int best = 0;
    for (int i = 999; i &gt;= 100; i--)
    {
        for (int j = i; j &gt;= 100; j--)
        {
            int num_to_test = i * j;

            if (num_to_test &lt;= best)
                break;

            if (is_palindrome(num_to_test)) {
                best = num_to_test;
                break;
            }
        }
    }
    cout &lt;&lt; best &lt;&lt; endl;
}

Using gcc -O3, this program ran in 0.03 seconds on my computer as opposed to 1.06 seconds, for around a 30x speedup.