0% found this document useful (0 votes)
9 views

Algorithms

Uploaded by

Siddhant patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Algorithms

Uploaded by

Siddhant patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Experiments -

Algorithms
Experiment 1: Gross Salary Calculation
Algorithm:
1. Start
2. Declare variables for basic salary, DA, HRA, and gross salary
3. Input basic salary from user
4. Calculate DA = 50% of basic salary
5. Calculate HRA = 40% of basic salary
6. Calculate gross salary = basic salary + DA + HRA
7. Display gross salary
8. Stop

Experiment 2: Student Grade


Classification
Algorithm:
1. Start
2. Declare variables for marks, maximum marks, and percentage
3. Input marks obtained and maximum marks
4. Calculate percentage = (marks obtained / maximum marks) × 100
5. If percentage > 75
Display "Grade: A+"
6. Else if percentage >= 60
Display "Grade: A"
7. Else if percentage >= 50
Display "Grade: B"
8. Else if percentage >= 40
Display "Grade: C"
9. Else
Display "Fail"
10. Stop
Experiment 3: Armstrong Number Check
Algorithm:
1. Start
2. Declare variables for input number, temporary variable, sum, and digit count
3. Input the number
4. Store number in temporary variable
5. Count number of digits in the number
6. Reset temporary variable to original number
7. While temporary number is not zero:
Extract last digit
Calculate power of digit with number of digits as exponent
Add result to sum
Remove last digit from temporary number
8. If sum equals original number
Display "Armstrong Number"
9. Else
Display "Not an Armstrong Number"
10. Stop

Experiment 4: Menu Driven Mathematical


Operations
Algorithm:
1. Start

2. Display menu with options:

Square root of number


Square of number
Cube of number
Check for prime
Factorial of number
Prime factors

3. Input choice

4. Input number
5. Based on choice:

For Square Root:

Calculate square root of number


Display result

For Square:

Calculate number × number


Display result

For Cube:

Calculate number × number × number


Display result

For Prime Check:

Set flag to true


For each number from 2 to number/2:
If number is divisible, set flag to false
Display result based on flag

For Factorial:

Initialize result to 1
For each number from 1 to input number:
Multiply result with current number
Display result

For Prime Factors:

For each number from 2 to input number:


While input is divisible by current number:
Display current number
Divide input by current number

For Invalid Choice:

Display error message

6. Stop

You might also like