popular post
Python Programming
PRACTICAL-1 Aim : (A) Write a python program to test whether a passed letter is vowel or not. m=[ 'a' , 'e' , 'i' , 'o' , 'u' , 'A' , 'E' , 'I' , 'O' , 'U' ] l=input( "Enter the Alphabet= " ) if l in m: print( "The alphabet is a Vowel." ) else : print( "The alphabet is not a Vowel" ) Output: (B) Write a python program to find out the factorial of a number. def fact(n) : if (n== 0 ) : return 1 else : return n * fact(n- 1 ) n=int(input( "Enter the number= " )) ans=fact(n) print( "the factorial of the number is:" ,ans) output: PRACTICAL-2 Aim: (A)Write a program to filter positive numbers from a list. a=list() b=list() n=int(input( "Enter the no. of Elements= " )) for i in range( 0 ,n): el=int(input( "Enter the Elements= " )) a.append(el) print(a) for i in a: if i> 0 : ...
Design And Analysis Of Algorithm
Implement following algorithm in iterative and recursive manner: A. GCD algorithm B. Factorial algorithm C. Fibonacci algorithm Factorial Algorithm import java.util.Scanner; public class Factorial { public static void main ( String [] args ) { int choice ; Scanner scanner = new Scanner ( System . in ); do { System . out . print ( "Enter a number: " ); int number = scanner . nextInt (); System . out . println ( "Select an approach:" ); System . out . println ( "1. Iterative" ); System . out . println ( "2. Recursive" ); System . out . println ( "3.Stop the Program" ); System . out . print ( "Enter your choice: " ); choice = scanner . nextInt (); ...
Comments
Post a Comment
Give your Feedback