A
aslamhenry
please key in any 5 digits number : 56789
and the ouput is
5678 9
567 89
56 789
5 6789
how to write those program......
my idea is like this...
#include <stdio.h>
void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;
printf("please key in any 5 digit number:");
scanf("%d",&num);
num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;
r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;
printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);
}
______________________________________________________________________________
the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....
anyone can tell what wrong with my coding...
and i really appriciate if someone can make it more efficient....
THX MUahhh
and the ouput is
5678 9
567 89
56 789
5 6789
how to write those program......
my idea is like this...
#include <stdio.h>
void main()
{
int num;
float num1,num2,num3,num4;
float r1,r2,r3,r4;
printf("please key in any 5 digit number:");
scanf("%d",&num);
num1=num/10;
num2=num/100;
num3=num/1000;
num4=num/10000 ;
r1=num%10;
r2=num%100 ;
r3=num%1000 ;
r4=num%10000 ;
printf("\n %.0f %.0f",num1,r1);
printf(" \n %.0f %.0f",num2,r2);
printf(" \n %.0f %.0f",num3,r3);
printf(" \n %.0f %.0f",num4,r4);
}
______________________________________________________________________________
the problem occur when i entered nnumber 56789.It output become
rubbish when i put 56789...
but if i key in 12345 the program excute nicely.....
anyone can tell what wrong with my coding...
and i really appriciate if someone can make it more efficient....
THX MUahhh