Search This Blog

Monday 7 March 2022

Practical No.11: Write a program to read 10 numbers and sort term into descending order

ACTIVITY 11

Practical No.11:
Write a program to read 10 numbers and sort term into descending order.







OR

By Sir Sajjad Akber Chandio
For SOURCE CODE See above codes





Practical No.10 Write a program that takes a number and prints its multiples up to 10.

ACTIVITY 10

Practical No.10:
Write a program that takes a number and prints its multiples up to 10.





OR

By Sir Sajjad Akber Chandio


ALGORITHM

  • step 1: start
  • step 2: Declare variables for loop and number
  • step 3: Input any number
  • step 4: Print multiples of number up to 10
  • step 5: Repeat step 4 10times (using for loop)
  • step 6: End


VIVA VOCE
ACTIVITY 10

Q.1: 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.2: How many types of loops are there?
Ans: C++ provides the following types of loops to handle looping requirements.
1. for loop
2. while loop
3. do-while loop

Q.3: Define for loop.
Ans: A for loop is a repetition or iteration control structure that repeats a statement or block of statements for a specified number of times. The for loop is commonly used when the number of iterations is known.

Q.4: Which function is used for printing output?
Ans: tout is the most common input function in C++ used as output function.

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


Practical No.9: Write a program to convert temperature from Fahrenheit into Celsius

ACTIVITY 9

Practical No.9:
Write a program to convert temperature from Fahrenheit into Celsius






OR

By Sir Sajjad Akber Chandio

ALGORITHM

  • step 1: start
  • step 2: Declare variables or Fahrenheit and Celsius
  • step 3: Take input for temperature in Fahrenheit
  • step 4: Convert Fahrenheit into Celsius by using formula i.e. (F – 32) * (5.0 / 9.0)
  • step 5: Print temperature value in Celsius
  • step 6: End


VIVA VOCE
ACTIVITY 9

Q.1: Define the range of Fahrenheit scale.
Ans: Fahrenheit scale is marked from 32° to 212°.

Q.2: Write down the formula of Fahrenheit into centigrade.
Ans: Fahrenheit into Celsius conversion is done by this formula:
Celsius = (Fahrenheit -32) * (5.0 / 9.0)

Q.3: Write down the formula of Celsius into Fahrenheit.
Ans: Fahrenheit into Celsius conversion is done by this formula:
Fahrenheit = {Celsius * (5.0 / 9.0)} + 32

Q.4: Define the range of Celsius scale.
Ans: Celsius scale is marked from 0° to 100°.

Q.5: What is the purpose of return keyword used in C++?
Ans: This statement is used to return the value to the operating system. By default, main function returns integer value 0.



Sunday 6 March 2022

Practical No.8: Write a program to input length in centimeter and convert it into meter

ACTIVITY 8

Practical No.8:
Write a program to input length in centimeter and convert it into meter





OR

By Sir Sajjad Akber Chandio


ALGORITHM

  • step 1: start
  • step 2: Declare variables for length and meter
  • step 3: Take input for length in centimeter
  • step 4: Convert it into meter by dividing centimeter value with 100
  • step 5: Print value in meter
  • step 6: End




Practical No.7: Write a program to find the area of a rectangle

ACTIVITY 7

Practical No.7:
Write a program to find the area of a rectangle.





OR

By Sir Sajjad Akber Chandio


ALGORITHM

  • step 1: start
  • step 2: Declare variables
  • step 3: Take input for length
  • step 4: Take input for width
  • step 5: calculate area by multiplying length by width
  • step 6: Print Area
  • step 7: End


VIVA VOCE
ACTIVITY 7

Q.1: What do you understand by an area of rectangle?
Ans: Area of rectangle is the region occupied by a rectangle within its four sides or boundaries.

Q.2: Write down the formula to calculate area of rectangle.
Ans: The area of a rectangle is the product of its length and width. So, area of rectangle = (length x width).

Q.3: Which type of operator is used in this program?
Ans: Arithmetic multiplication operator is used in this program.

Q.4: What is the purpose of return keyword used in C++?
Ans: This statement is used to return the value to the operating system. By default, main function returns integer value 0.

Q.5: Function cout belongs to which header file?
Ans: cout function belongs to header file iostream.


Practical No.6: Write a program to check whether a number is positive, negative or zero.

ACTIVITY 6

Practical No.6:
Write a program to check whether a number is positive, negative or zero






OR

By Sir Sajjad Akber Chandio



VIVA VOCE
ACTIVITY 6

Q.1: What is an integer?
Ans: A number which is a whole number and cannot contain decimal point is called an integer.

Q.2: What is a positive number?
Ans: A number which is greater than zero is called a positive number.

Q.3 What is a negative number?
Ans: A number which is less than zero is called a negative number.

Q.4 What is if condition?
Ans: An if condition is a selection control structure that compares two values and evaluates the answer as true or false.


Saturday 5 March 2022

Practical No.5: Write a program to compute the total and average of six numbers.

ACTIVITY 5

Practical No.5:
Write a program to compute the total and average of six numbers.





OR

By Sir Sajjad Akber Chandio




VIVA VOCE

ACTIVITY 5

Q.1: What is the object of this program?
Ans: Object of this program is to calculate total and average of given numbers.

Q.2: What is the formula to calculate an average?
Ans: Total of the numbers divided by the total number of values in the set.

Q.3: Which operator is used to calculate total?
Ans: Addition operator is used to calculate total.

Q.4: What are binary operators?
Ans: Those operators that are used to performs operation on two operands are known as binary operators.



Practical No.4: Write a program to add, subtract, multiply and divide two numbers using arithmetic operators.

ACTIVITY 4

Practical No.4:
Write a program to add, subtract, multiply and divide two numbers using arithmetic operators.



ALGORITHM
step1: start
step2: Declare variables for numbers and operations
step3: Take Input from user as two numbers
step4: Perform addition, subtraction, multiplication and division by using arithmetic operation
step5: Print results of addition, subtraction, multiplication and division
step6: Stop

(Note: In below codes ,
  • on line number 7, we write division rather than div
  • on line number 25, we write Addition rather than sum
because the source code gave error on running.)


OR

By Sir Sajjad Akber Chandio






Practical No.3: Write a program to get 10 characters as a string using getch()function and print all characters.

ACTIVITY 3

Practical No.3:
Write a program to get 10 characters as a string using getch()function and print all characters.


NOTE: A program with array 'STRING' using getch() function and print all characters. (as mentioned in question)
SOURCE CODE:


OR


 NOTE: A program with array 'CHAR' using getch() function and print all characters.
For Algorithm and Flow Chart See above



Special Thanks To Sir Sajjad Akber Chandio