-1

Like @JamesCherril has stated that the multiplication can easily be expressed with continuous of addition.
So basically a x b = b + b .... b (continously add b, a times).
For example: 3 x 1002 = 1002 + 1002 + 1002.

unsigned int multiply(unsigned int a, unsigned int b) {
    unsigned int result = 0;
    for (unsigned int i = 0; i < a; i++) {
        result += b;
    }
    return result;
}

Can we be more efficient than this one? We can slightly improve this function further. Noticed that multiply(3, 1002) run faster than multiply(1002, 3). So, we now know that our code run faster if a is small and b is large. So, we can swap the b with a if b is smaller than a

unsigned int multiply(unsigned int a, unsigned int b) {
    if (a > b) return multiply(b, a);

    unsigned int result = 0;
    for (unsigned int i = 0; i < a; i++) {
        result += b;
    }
    return result;
}

Everything look good now, but can we do better? Of course, we can do even better. We know that we can compute a x 2^k very fast without using any multiplication operation using only shift left. So basically, a x 2^k is the same as a << k. Using this fact, we can easy compute 100 x 5 as following 100 << 2 + 100

unsigned int multiply2(unsigned int a, unsigned int b) {
    unsigned int result = 0;
    unsigned int bits ...
-1

[QUOTE]But once you converting string which has fixed value. Then how it can be treat as different value?[/QUOTE]The string you have is represented in decimal float-point, while [B]atof[/B] function converting that string into binary float-point. Some fixed values in decimal float-point cannot be exactly converted into binary float-point. In this case, [B]atof[/B] function will choose the closest approximate value to the decimal float-point. Dealing with float-point can be frustrated, you should better read how it works.

Votes + Comments
Thank you for repeating what I posted.
-1

If an [B]Armstrong number[/B] is a number such that the sum of its digits raised to the third power is equal to the number itself, then I am sure that there are only 5 Armstrong numbers that does exist in this world. Practically, when the number of digit grow, the sum of raising to the third power of each digit won't able to produce larger enough result to be equal to the number.

[INDENT][B]For example:[/B]
99999 = 9^3 + 9^3 + 9^3 + 9^3 + 9^3 = 3645.[/INDENT]

The above example has proved that even we have the largest number in each digit we still cannot produce larger enough result to be equal to its number.

-1

How about my solution. Faster and can handle more rows. However,
this code is written in C. I will translate it to C++, if you want.

[CODE]#include <stdio.h>

include <stdlib.h>

int main()
{
int n, i, j;
printf("How many rows you want to show?: ");
scanf("%d", &n);
for (i=0; i<n; i++) {
int c = 1;
for(j=i; j>=0; j--) {
printf(" %d", c);
c = c * j/(i-j+1);
}
printf("\n");
}
}
[/CODE]