Skip to main content

Featured

functions in Python

c++ program to concatenate two integers

/*c++ program to concatenate two integer numbers provided the smaller number precedes the bigger number. For Example: if the entered numbers are 782 and 245 then concatenated number will be 245782*/

#include<iostream.h>
void main()
{
long a,b,max,min,store,ten=1,final;
int digcnt=0;
cout<<"\nEnter two numbers\n";
cin>>a>>b;
max=(a>b)?a:b;
min=(a<b)?a:b;
store=max;
while(max>0)
{
max/=10;
digcnt++;
}
for(int i=1;i<=digcnt;i++)
{
ten=ten*10;
}
min*=ten;
final=min+store;
cout<<"Concatenated Number : "<<final;
}

OUTPUT:

Comments

Popular Posts