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

Procedure C Lab-16

This document contains algorithms for several tasks: 1) Checking if a character is a vowel or consonant. 2) Generating student result classes based on percentage scores. 3) Printing color codes for resistors given values and tolerances. 4) Adding two matrices using pointers. 5) Sorting a list of numbers using a user-defined sorting function.
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Procedure C Lab-16

This document contains algorithms for several tasks: 1) Checking if a character is a vowel or consonant. 2) Generating student result classes based on percentage scores. 3) Printing color codes for resistors given values and tolerances. 4) Adding two matrices using pointers. 5) Sorting a list of numbers using a user-defined sorting function.
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Algorithm For Checking If Given Character Is Vowel Or Not

Step 1: Start .
Step 2: Reserve space for storing read character.
Step 3: Request & read character.
Step 4: If given character is in uppercase convert to lowercase.
Step 5: Compare the character to 'a','e','i','o' & 'u' if any match then print as vowel.
Step 6: If not matching print consonant .
Step 7: Stop .

Algorithm For Student Result Class Generation

Step 1: Start.
Step 2: Reserve space for total marks, maximum marks & percentage.
Step 3: Request & read obtained maximum marks .
Step 4: Request & read total maximum marks.
Step 5: Calculate percentage
Total obtained marks
= X100
Total maximum marks

Step 6: Compare & print if percentage .


a) More than OR equal to 75 as “DISTINCTION”.
b) Else if more than OR equal to 60 and less than 75 as “FIRST CLASS”.
c) OR else if > or equal to 50 & < 60 as “SECOND CLASS” .
d) OR else if > or equal to 35 & <50 as “PASS”.
e) If no above combination match with percentage then print “NOT CLEARED”.

Step 7: Hold the screen / display.


Step 8: Stop
Algorithm to print color code of resistor given the resistance and standard
tolerance.
Step 1: Start.
Step 2: Reserve space for value, first band,2nd band, tolerance, count variable & other temp variable.
Step 3: Request and read resistance value & tolerance.
Step 4: Extract multiplier by checking
if value <99, multiplier=0
<999, multiplier=1
<9999, multiplier=2
<99999, multiplier=3
<999999, multiplier=4
<9999999, multiplier=5
<99999999, multiplier=6
<999999999, multiplier=7
<9999999999, multiplier=8
<99999999999, multiplier=9
Step 5: Extract the 1st & 2nd band
(a) Divide value by 10
(b) Store remainder in array
(c) Divide value by 10 & consider quotient for next division.
(d) Check if value is zero, if yes go to step 6, else go to step 5(a).
Step 6: Separate 1st band and 2nd band from rest of digits.
Step 7: Compare 1st band and print.
(a) Black for 0
Brown for 1
Red for 2
Orange for 3
Yellow for 4
Green for 5
Blue for 6
Violet for 7
Gray for 8
White for 9
Step 8: Compare 2nd band & print
Black for 0
Brown for 1
Red for 2
Orange for 3
Yellow for 4
Green for 5
Blue for 6
Violet for 7
Gray for 8
White for 9
Step 9: Compare 3rd band / tolerance band & print.
Gold for 5
Silver for 10
No band for 20
Step 10: Stop.
Algorithm to Add two matrices using pointers

Step1: Start.
Step2: Reserve the space for two data matrices, sum matrix, row, column values and for count
variables.
Step 3: Request and read the row and column of matrices.
Step4: Request and read the elements of first matrix. Store the values read by pointing memory
location.
Step5: Request and read the elements of second matrix. Store the values read by pointing memory
location.
Step6: Point to each element of data matrices to add the store the sum by pointing to location of sum
matrix.
Step7: Print the sum matrix.
Step8: Stop.
Algorithm to Sort a list of numbers using user defined function
Step1: Start.
Step2: Reserve the space for list, length of list and count variables.
Step3: Request and read the number of elements.
Step4: Request and read the elements of list.
Step 5: Print the unsorted list.
Step 6: Call the user defined function to sort the list, pass length of list and elements of list.
Step7: print the sorted list.
Step8: Stop
Algorithm to for sorting in user defined function

Step 1: Receive the length of the list and elements of list.


Step 2: Declare the local variable.
Step 3: Compare the previous element of list with next.
Step 4: Swap the elements if previous element is greater than or equal to next element.
Step 5: If comparison of all elements are completed then go to step 6, else go to step 3.
Step 6: return to main program.

You might also like