PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION I/P: 3 O/P: 6 SOLUTION: package N umbers ; import java . util .*; public class Factorial { static int factorial ( int n ) { return ( n > 1 ) ? n * factorial ( n - 1 ) : 1 ; } public static void main ( String [] args ) { Scanner sc = new Scanner ( System . in ); int n = sc . nextInt (); int result ...
Program to Copy One Array to Another using Assignment operator Program: public class CopyArrayAssignment { public static void main ( String args []) { int arr []={ 1 , 2 , 3 , 4 , 5 } ; int copyarr []= arr ; for ( int i : copyarr ) { System . out . println ( i ) ; } } } // 1 // 2 // 3 // 4 // 5
PROGRAM TO FIND THE COUNT OF PARTICULAR NUMBER IN AN ARRAY I/P: 5 1 0 2 0 0 O/P: 3 This program explains how many zeros present in the zero PROGRAM: import java . util .*; public class ZeroCount { public static void main ( String args []) { Scanner sc = new Scanner ( System . in ); int iNum = sc . nextInt (); int arr []= new int [ iNum ]; for ( int i = 0 ; i < iNum ; i ++) { arr [ i ]= sc . nextInt (); } int count = 0 ; ...
Comments
Post a Comment