C++ program to accept three digits and print all possible combinations from these digits



#include<iostream.h>
#include<conio.h>
void main()
{
int a[3];
clrscr();
cout<<"Enter three digits :"<<endl;
cin>>a[0]>>a[1]>>a[2];
for (int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
for (int k=0;k<3;k++)
{
if (i!=j&&i!=k&&j!=k)
cout<<endl<<endl<<a[i]<<a[j]<<a[k];
}
}
}
getch();
}

OUTPUT:

Enter three digits :
1 2 3                                                                          
                                                                                
                                                                               
123                                                                            

132                                                                             
                                                                               
213                                                                            
                                                                                
231                                                                            
                                                                               
312                                                                             
                                                                               
321

No comments:

Post a Comment