Monday, November 29, 2010

// pen pencil algorithm

#include
#include
void main()
{
int num1,num2,sum=0,res=0,m=1,temp=0;
printf("enter the numbers");
scanf("%d%d",&num1,&num2);
while(num2) // works until num2 becomes
{
sum=0; //initialize sum
rem=num2%10;
num2/=10;
sum=num1*rem;
temp=sum*m;
printf("%d",temp);
res=res+temp; //adds two products
m*=10;
}
printf("%d",res);
getch();
}

No comments:

Post a Comment