Re: correction
<aslamhenry@yahoo.com> wrote in message
news:1190127887.713876.296160@r29g2000hsg.googlegroups.com...
On Sep 18, 10:05 pm, aslamhe...@yahoo.com wrote:
On Sep 18, 10:00 pm, aslamhe...@yahoo.com wrote:
On Sep 18, 9:54 pm, "Jim Langston" <tazmas...@rocketmail.com> wrote:
<aslamhe...@yahoo.com> wrote in message
news:1190122341.695787.266290@y42g2000hsy.googlegroups.com...
On Sep 18, 9:30 pm, "Victor Bazarov" <v.Abaza...@comAcast.net>
wrote:
aslamhe...@yahoo.com wrote:
[..]
erm...how about if im using float...ant printf as %.0f..huhuhu
but
still i dont know how to saparate those digit as shown uhuhu
BTW, what's "uhuhu" or "huhuhu"?
[Snip previous discussion and unrelated code]
check out this code why it doesnt work huhuhu
#include <stdio.h>
int main(void)
{
float num;
int i, j, x ;
In C++ it is customary to declare variables as close to their first use as
possible. So get rid of the
int i,j,x;
since we're not using them yet.
printf("please key in any 5 digit number:");
scanf("%f",&num);
Since you are asking in a C++ newsgroup and not C, you should do it the C++
way.
#include <iostream>
at top.
std::cin >> num;
for ( i=0 ; 5>i ; ++i){
for ( int i = 0; i <= 5; ++i )
is more common.
for(j=0 ; i>j ; ++j){
printf(" ") ;
}
That looks okay.
for( x = j+1 ; 5 >= x ; ++x){
printf("%.0f", num);
}
putchar('\n');
}
But, you have a 5 digit number. First you want to print all 5 digits.
Which would be the number / 1
Then print 4 digits, number / 10
then print 3 digits, number / 100
see a pattern?
Consider:
std::cout << num / ( i * 10 );
Then you would want to print a space.
std::cout << " ";
Then you would want to print the remainder.
std::cout << num % ( i * 10 );
return 0;
}
Since you are asking in a C++ newsgroup, don't use printf, use std::cout.
Don't use scanf, use std::cin.