Search This Blog

Monday, 7 March 2022

Practical No.13: Write a program to read an integer n and print the factorial of n.

ACTIVITY 13

Practical No.13:
Write a program to read an integer n and print the factorial of n.





OR

By Sir Sajjad Akber Chandio


ALGORITHM

  • step 1: start
  • step 2: Declare variables for number, factorial and loop
  • step 3: Input positive integer number
  • step 4: Use factorial formula i.e. factorial = factorial * integer number
  • step 5: Repeat step # 4 until integer number
  • step 6: Print factorial value
  • step 7: End


VIVA VOCE
ACTIVITY 13

Q.1: What do you understand by factorial?
Ans: Factorial is the product of all positive integers less than or equal to a given positive integer and denoted by that integer and an exclamation point.

Q.2: Write down the example of factorial of a number.
Ans: Factorial seven is written 7!, calculate as:
1 x 2 x 3 x 4 x 5 x 6 x 7.
Factorial zero is defined as equal to 1.

Q.3: What is loop?
Ans: Iteration or loop in computer programming, is a process wherein a set of instructions or structures are repeated in a sequence a specified number of times until a condition is true.

Q.4: How many types of loop are there?
Ans: C++ provides following types of loop to handle looping requirement.
1. for loop
2. while loop
3. do-while loop

Q.5: What are the escape sequence in C++?
Ans: Escape sequence is a set of characters that convey a special meaning to the program.

Q.6: What is the use of "namespace" in C++?
Ans: Namespace are used to organize code into logical groups and to prevent name collisions that can occur especially when our code base includes multiple libraries.



No comments:

Post a Comment