Featured
- Get link
- X
- Other Apps
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:
#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:
- Get link
- X
- Other Apps
Labels:
c++ program to concatenate two integer numbers
c++ program to concatenate two integers
c++ program to join two integer numbers
how to combine two numbers into one
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment