Wednesday, July 22, 2009
Armstrong numbers in core java
class abc
{
public static void main(String[] arr)
{
int c=Integer.parseInt(arr[0]);
int num1=c;
int p=0;
int sum=0;
do
{
p=((c%10)*(c%10)*(c%10));
c=c/10;
sum=sum+p;
}
while(c>0);
if(sum==num1)
{
System.out.print("\n\n number is armstrong");
}
else
{
System.out.print("\n\n number is not armstrong");
}
}
}
number formation in core java
simple prog in core java
Tuesday, July 21, 2009
java 2 dimmensional array
//MY JAVA WORK BHARAT
class abc
{
public static void main(String[] arr)
{
int [][] y = new int [3][3];
int m=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
y[i][j]=Integer.parseInt(arr[m++]);
}}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(" " +y[i][j]);
}
System.out.print("\n");
}
}}
//MY JAVA WORK BHARAT
class abc
{
public static void main(String[] arr)
{
int [][] y = new int [3][3];
int m=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
y[i][j]=Integer.parseInt(arr[m++]);
}}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(" " +y[i][j]);
}
System.out.print("\n");
}
}}
//MY JAVA WORK BHARAT
Subscribe to:
Posts (Atom)