Posts

Design And Analysis Of Algorithm

Image
  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 ();         long startTime = System . nanoTime (); // Start execution time         long result ;         switch (choice) {             case 1 :                 result = factorialItera

Basic Programming in Python

Image
  '''#1.Display hello world print("Hello world")''' '''#2. Data types i=(5) f=(6.13665665454545) c="a" print(i,f,c)''' '''#3.Basic calculator a=float(input("Enter the value of a=")) b=float(input("Enter the value of b=")) add=print("Addition=",a+b) sub=print("Subtraction=",a-b) mul=print("Multiplication=",a*b) div=print("Division=",a/b)''' '''#4. Volume of cube a=int(input("Enter the value=")) volume=print("Volume of cube=",a*a*a)''' '''#5.Swaping the number using the third variable a=6 b=7 c=0 print("Before Swapping a=",a,"b=",b) c=a a=b b=c print("After Swapping a=",a,"b=",b)''' ''''#6. Check no. is odd or even a=int(input("Enter the value=")) if(a%2==0):     print(a,"is an Even number") else:

OS(Operating System)

Image
       OS LAB MANUAL Practicals 1-4

Python Programming

Image
  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 :