Anda di halaman 1dari 19

# UNIT-I

1) Draw a logical flow chart for computing mean and range of a set of number

Algorithm

Step 1 Start

## Step 12 Write mean, maximum and minimum

Step 13 Stop
2) Draw a logical flow chart for computing electricity charges as per the Tamil Nadu
Electricity Board (TNEB) Tariff Chart given the units consumed.

## Units Consumed (bi-monthly) Charges Fixed Charges/

(Rs/unit) Service (Rs)
0-100 Nil Nil
Above 100 units and upto 200 unit
0-100 0
101-200 1.50 20
Above 200 units and upto 500 unit
0-100 0
101-200 2.00 30
201-500 3.00
Above 500 units
0-100 0
101-200 3.50
201-500 4.60 50
Above 500 6.60

Step 1 Start

Step 2 Read current and past meter reading. Let it be cmr and pmr.

## Step 4 If n > 500 Compute bill = ((n – 500)*6.60) + (300*4.60)+(100*3.5) +50)

goto Step 8

Step 5 If n > 200 Compute bill = ((n – 200)*3.00) + (100*2.00) +30) goto Step 8

## Step 8 Write bill

Step 9 Stop
𝐴𝑖
3) Draw a logical flow chart for computing 𝑓(𝑥) = ∑𝑖=𝑛
𝑖=0 ,.
(1+𝑥)𝑖
UNIT II
1) Design and develop programs for evaluating the equations : 𝑣 = 𝑢 + 𝑎𝑡; 𝑠 = 𝑢𝑡 +
𝑎𝑡 2 2𝐴𝐷
; 𝑣 2 − 𝑢2 = 2𝑎𝑠 𝑎𝑛𝑑 𝑄 = √ .
2 𝐶𝑖

Aim:
To Design and develop C programs for evaluating the equations : 𝑣 = 𝑢 + 𝑎𝑡; 𝑠 =
𝑎𝑡 2 2𝐴𝐷
𝑢𝑡 + ; 𝑣 2 − 𝑢2 = 2𝑎𝑠 𝑎𝑛𝑑 𝑄 = √ .
2 𝐶

Algorithm:
Step1: Start.
Step2: Read the values of u,a,t.
Step3: Compute v = u + (a*t) and display the result of velocity.
Step4: Compute s = (u*t) + (0.5*a*(t*t)) and display the result of displacement.
Step5: Compute l = ((v*v) - (u*u)).
Step6: Compute p = 2 * a*s
Step 7: Check l is equal to p.
Step7: Read the value of A,D,C
Step8: Compute q = sqrt((2*A*D) / C).
Step9: Display the result of q.
Step10: Stop.
2) Design and develop a program to display a two digit integer in word. Example: 38 →
Thirty eight. Implement it.

Aim:
To Design and develop a program to display a two digit integer in word.

Algorithm:
Step 1: Start.
Step 2: Read the values of n.
Step 3: Write the function f1 to convert one’s digit into words.
Step 4: Write the function f2 to convert the numbers ten to nineteen into words.
Step 5: Write the function f3 to convert ten’s digit into words.
Step 6: If (n < 10)
Call the function f1(n). Print the digit in words and exit.
Else go to step 7.
Step 7: If (n < 20)
Call the function f2(n). Print the digit in words and exit.
Step 8: If (n<100)
Compute units = n % 10
Compute tens = n / 10
Call the function f3(tens) and f1(units) and print the digit in words.
Step 9:Stop.
3) Design and develop a program for computing the sum of three fractions. The fractions
and sum shall be read / displayed in the form of numerators and denominators.
Implement it.

Aim:
To design and develop a program for computing the sum of three fractions.

Algorithm:

Step 1: Start.
Step 2: Read the values of numerators of 3 fractions (n1, n2, n3) and denominators of 3
fractions (d1, d2, d3).
Step 3: Write the function findLCM(d1,d2,d3), which returns the lcm of d1,d2,d3.
3.1 Find the minimum of d1, d2, d3 and assign to lcm
3.2 Increment lcm until ((lcm%d1) != 0 || (lcm%d2) != 0 || (lcm%d3) != 0).
Step 4: Assign lcm to resD
Step 5: Compute (lcm / d1)*n1 + (lcm / d2)*n2 + (lcm / d3)*n3 and assign to resN
Step 6: Stop.
UNIT III

1) Design and develop a program in C for arranging three distinct objects colored
Red, Green, Blue (RGB) in all possible orders. Implement it.

Aim:
Design and develop a program in C for arranging seven distinct objects colored Violet, Indigo,
Blue, Green, Yellow, Orange and Red (VIBGYOR) in all possible orders.
Algorithm:
Step 1: Start.
Step 2: Create an array ‘str’ containing ‘R’,’G’,’B’
Step 3: for a 1to 3
Step 4: for b 1 to3
Step 5: for c1 to 3
Step 6: if ( a not equal to b and a not equal to c and b not equal to c )
Display str[a],str[b],str[c]

Step 7: Stop.
2) Design and develop a program for generating Pascal’s Triangle using recursive function
for evaluating factorial. Implement it

Aim:
To Design and develop a program for generating Pascal’s Triangle using recursive
function for evaluating factorial.

Pseudocode:
Begin.
Read the number of lines to be printed ( line)
Write recursive function to compute fact(n)
for I0 to line
for j0 to line-i-1
Write <space>
for j0 to i
write ( fact(i) / (fact(j)*fact(i - j))
End

## /* Computing factorial using recursion */

fact(n)
begin
if (n equals 0) or (n equals 1)
return 1
else
return n*fact(n-1)
end
3) Design and develop a modular program for performing 2D transformations: translation,
scaling and rotation. Implement it. Use an illustrative example of your choice.

Aim:
To Design and develop a modular program for performing 2D transformations: translation,
scaling and rotation.
Algorithm:
Step 1: Start.
Step 2: Write functions to perform translation, scaling, rotation
Step 3: GET choice from user and call appropriate function
Step 4: Call the function translate ()
Step 4.1: Read the coordinates of the rectangle x1,x2,y1,y2
Step 4.2: Plot the rectangle by using appropriate graphic function rectangle()
Step 4.3: Read the translation details xtrans and ytrans
Step 4.4: Compute x1 = x1 + xtran
Step 4.5: Compute Y1 = y1 + ytran
Step 4.6: Compute x2 = x2 + xtran
Step 4.7: Compute y2 = y2 + ytran
Step 4.8: Plot the rectangle

## Step 5: Call the function scale()

Step 5.1: Read the coordinates of the rectangle x1,x2,y1,y2
Step 5.2: Plot the rectangle by using appropriate graphic function rectangle()
Step 5.3: Read the translation details xtrans and ytrans
Step 5.4: Compute x1 = x1 + xtran
Step 5.5: Compute Y1 = y1 + ytran
Step 5.6: Compute x2 = x2 + xtran
Step 5.7: Compute y2 = y2 + ytran
Step 5.8: Plot the rectangle
Step 6: Call the function rotate()
Step 6.1 Read the coordinates of the line
Step 6.2 Plot the line by using appropriate graphic function (line())
Step 6.3 Read angle of rotation r
Step 6.4 Compute t = r*(3.14/180);
Step 6.5 Compute nx1 = abs(x1*cos(t) - y1*sin(t))
Step 6.6 Compute ny1 = abs(x1*sin(t) + y1*cos(t))
Step 6.7 Compute nx2 = abs(x2*cos(t) - y2*sin(t))
Step 6.8 Compute ny2 = abs(x2*sin(t) + y2*cos(t))
Step 6.9 Plot the line
UNIT IV

1. The records of VTU students comprise the fields: VTU No, Name, Branch of Study
and Gender. Use array of structures for storing such records randomly. Design and
develop a program for clustering the records based on branch of study and gender.
Implement it.

Aim:
To design and develop a program for clustering the records based on branch of study and
gender using array of structures. The records of VTU students comprise the fields: VTU No,
Name, Branch of Study and Gender.

Algorithm:
Step 1: Start.
Step 2: Create a student record containing vtuno, name, branch and gender
Step 3: Get the record details and store as array of structures
Step 4: Read the search field (branch b) for clustering the records
Step 6 : If record contains the required branch of study,
Display the record details of student
Step 7: Repeat Step 5-6 until there are records to be processed
Step 8: Read the search field (gender g) for clustering the records
Step 10 : If record contains the required gender,
Display the record details of student
Step 11: Stop.
2. Design and develop a modular program in C for performing addition, subtraction and
multiplication operations on two degree polynomials in two variables. Use singly

Aim:
To design and develop a modular program in C for performing addition, subtraction and
multiplication operations on two 𝑛𝑡ℎ degree polynomials in two variables using singly linked
lists.
Algorithm:
Step 1: Start.
Step 2: Represent the polynomials by coefficients and degrees.
Step 3: Create two polynomials using singly linked list.
Step 4: Read two polynomials by entering the respective coefficients and degrees.
Step 5: Perform addition of two polynomials by adding the respective coefficients of same
degrees and display the result .
Step 6: Perform subtraction of two polynomials by subtracting the respective coefficients of
same degrees and display the result.
Step 7: Perform multiplication of two polynomials by multiplying the respective coefficients
and adding the degrees and display the result.
3. Design and develop a program in C for generating Fibonacci series consisting of at least
n numbers and sorting them in descending order. Use recursive Fibonacci function.
Implement it.

Aim:
Design and develop a program in C for generating Fibonacci series consisting of at least n
numbers and sorting them in descending order. Use recursive Fibonacci function
Algorithm:
Step 1: Start.
Step 2: Read the number of fibonacci term (t) to be printed
Step 3: Write the recursive fibonacci function fib (n) to generate the given term
Step 4: Repeat Step 5 with the initial value of i=t, and decrementing i by 1 until i becomes 0
Step 5: Call function fib (i) and print the result
Step 5: Stop

## /* Recursive Fibonacci function */

fib(n)
begin
if (n<2)
return n
else
return (fib(n-1)+fib(n-2))
end
Unit-V
i) Design and develop a program in C for merging at least 3 text files. Assume that the
records of the files are sequentially ordered based on a primary key. Implement it.

Aim:
To design and develop a program in C for merging at least three text files assuming
that the records of the files are sequentially ordered based on a primary key.

Algorithm:
Step1: Start.
Step2: Create three text files f1, f2, f3 containing VtuNo and names.
Step3: Open the file f1, f2 in read mode.
Step4: By comparing the primary key value i.e. Vtuno, merge f1, f2 and store it in file f4.
Step5: Merge two files f4, f3 and store it in file f5.
Step6: Stop.

ii) Design and develop a modular program in C for filtering the records of binary file given
the range of primary key values. Implement it.

Aim:
To design and develop a modular program in C for filtering the records of binary file
given the range of primary key values.

Algorithm:
Step 1: Start.
Step 2: Create a binary file containing Vtuno and name.
Step 3: Read the range to print the values.
Step 4: Retrieve the last digit of the Vtuno to locate the record.
Step 5: Using fseek function, locate the file pointer to the respective record.
Step 6: Read and display the number of records in the range.
Step 7: Stop.
iii) Design and develop a Checkout Billing System for Saravana Stores. Use binary file(s).
Implement it.

Aim:
To design and develop a Checkout Billing System for Saravana Stores.

Algorithm:

Step 1: Start.
Step 2: Create the master file containing item_code, item_name, unit_price.
Step 3: Create the transaction file containing item_code and quantity.
Step 4: Read a records in the transaction file
Step 5: Using item_code’s last digit to locate the corresponding record in the master file
and get the unit price information.
Step 5: Compute price = unit price x quantity.
Step 6: Display the item name, item code, quantity, price
Step 7: Compute totalBill = totalBill+price
Step 7: Repeat the Step 4 to Step 7, until there are records in the transaction file.
Step 8: Display total bill.
Step 9: Stop.