0% found this document useful (0 votes)
85 views3 pages

Reverse Number: //output

The document contains code for 3 Java programs - one that reverses an integer number, one that prints the Fibonacci sequence up to the 10th term, and one that prints a triangular pattern. The reverse number program takes a number as input, iterates through its digits, and outputs the number in reverse order. The Fibonacci program initializes two values, adds them in a loop to generate subsequent terms, and prints each term. The pattern program uses nested for loops to print increasing integers in a triangular format with each new line.

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views3 pages

Reverse Number: //output

The document contains code for 3 Java programs - one that reverses an integer number, one that prints the Fibonacci sequence up to the 10th term, and one that prints a triangular pattern. The reverse number program takes a number as input, iterates through its digits, and outputs the number in reverse order. The Fibonacci program initializes two values, adds them in a loop to generate subsequent terms, and prints each term. The pattern program uses nested for loops to print increasing integers in a triangular format with each new line.

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Reverse Number

class Reverse
{
public static void main(String [] args)
{
int x=23874,num,result=0;
System.out.println("value of given number is: "+x);
while(x>0)
{
num=x%10;
result=result*10+num;
x=x/10;
}
System.out.println("Reverse of Number is: "+result);
}
}
//Output
Fibonacci
class Fibonacci
{
public static void main(String [] args)
{
int a=0,b=1,temp,i;
for (i=1;i<=10 ;i++ )
{
System.out.print(a+" ");
temp=a+b;
a=b;
b=temp;
}
}
}
//Output
Pattern
class Pattern
{
public static void main(String[] args)
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(j<=i)
{
System.out.print(i+" ");
}
}
System.out.print("\n");
}

}
}
//Output

You might also like