************************************************************************ W.A.P TO CHECK GIVEN NUMBER IS PALINDROME NUMBER OR NOT ************************************************************************ JAVA Program import java.util.Scanner; class demo { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter the Number: " ); int n= sc.nextInt(); // System.out.println("\nEntered number is: "+n); int temp=0,x; int n2= n; while (n>0){ x=n%10; n=n/10; temp= temp*10+x; } if (temp == n2) { System.out.println("Number is Panildrome " ); } else{ System.out.println("Number is not Panildrome " ); } }} Online compiler Output: Enter any Number : 161 Number is Palindrome *****************************
************************************************************************ Write a c program to print Fibonacci series without using recursion and using recursion. Input: 10 Output: 0 1 1 2 3 5 8 13 21 34 ************************************************************************ JAVA Program //import java.util.Date; import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { // Date now = new Date(); Scanner sc= new Scanner(System.in); int x,y,z,n,i; y=z=0; x=1; System.out.println("Enter value of n: "); n=sc.nextInt(); System.out.println("FIBONACCI SERIES: " ); for(i=0;i<n;i++) { System.out.print(" "+z); z=x+y; x=y; y=z; } } } Online compiler Output: Input: 10 Output: 0 1 1 2 3 5 8 13 21 34 ************************************************************************ C Progr
Comments
Post a Comment