Posts

Showing posts from October 20, 2019

Important Algorithm For CPRG Theory Exam

Most important Algorithms for IPLC theory exam : 1. Write an algorithm to input a number and display factorial of that number. ANS) //Algorithm to calculate the factorial of a number step 1. Start step 2. Read the number n step 3. declare              i=1, fact=1 step 4. Repeat step 4 through 6 until i=n step 5. fact=fact*i step 6. i=i+1 step 7. Print fact step 8. Stop 2. Write an algorithm to Generate Fibonacci series. ANS) Step 1: Start Step 2: Declare variables n, n1, n2, n3, i. Step 3: Accept value of N from user. Step 4: if N < 2, display message “Enter num greter than 2” and go to step 9. Step 5: Initialize variables n1 = 0, n2 = 1, i = 0 Step 6: Display n1, n2   Step 7: Compute n3 = n1 + n2 Step 8: Repeat following statements until i < N         Display N3         N1 = N2         N2 = N3       ...