Professional Documents
Culture Documents
Our Students
Important links
LEFT SHIFT RIGHT SHIFT SMALLEST AND LARGEST
Mock Test
Write a program to input a number, now left shift the digits of the
School Projects number to create the largest number and right shift the digits to create
the smallest number. Print the numbers being generated during left
Free 100 java programs
shift and right shift. Finally display all perfect numbers from smallest to
ICSE RESULT 2010 largest as follows:‐
ICSE RESULT 2011 Input :
ICSE RESULT 2012
1693
ICSE RESULT 2013 output
Left Shift combinations :
Our Branches 6931
9316
11C, Bose Para Road, Barisha
3169
Sakher Bazar, Kolkata ‐ 700008 1693
47A, Bhupen Roy Road, Behala
Maximum number :9316
Manton James Long Crossing,
Right Shift combinations :
3169
Kolkata ‐ 700034
9316
6931
Ph: 98300 10279, 72780 51710 1693
Minimum number :1693
Perfect squares are :
1764
1849
1936
2025
2116
......
......
......
9025
9216
class leftshiftlargest
{
void display(int n)
{
int cnt=countdig(n);
int ar[]=new int[cnt],cp=n,cpcnt=cnt;
while(cpcnt>0)
{
ar[cpcnt‐1]=cp%10;
cpcnt‐‐;
cp=cp/10;
}
int max=0,min=0;
System.out.println("Left Shift combinations :");
for(int i=0;i<=cnt‐1;i++)
{
int l=ar[0];
for(int j=0;j<=cnt‐2;j++)
ar[j]=ar[j+1];
ar[cnt‐1]=l;
int num=0;
for(int k=1;k<=cnt;k++)
num=num*10+ar[k‐1];
System.out.println(num+" ");
if(num>max) max=num;
}
System.out.println("Maximum number :"+max);
System.out.println("Right Shift combinations :");
for(int i=0;i<=cnt‐1;i++)
{
int l=ar[cnt‐1];
for(int z=cnt‐2;z>=0;z‐‐)
ar[z+1]=ar[z];
ar[0]=l;
int num=0;
for(int k=1;k<=cnt;k++)
num=num*10+ar[k‐1];
if(i==0)
min=num;
if(num<=min)min=num;
System.out.println(num+" ");
}
System.out.print("Minimum number :"+min);
persquare(min,max);
}
int countdig(int n)
{
int c=0;
while(n'>'0)
{
c++;
n/=10;
}
return c;
}
void persquare(int m,int n)
{
System.out.println("\nPerfect squares are :");
for(int i=m;i<=n;i++)
{
int sq=(int)Math.sqrt(i);
if(sq==Math.sqrt(i))
System.out.println(i);
}
}//end of function
}//end of class