socovtu.files.wordpress.com  · web view11/3/2017  · to design and develop a program to display...

23
Aim: To Design and develop C programs for evaluating the equations :v=u+ at;s=ut + at 2 2 ;v 2 u 2 =2 asQ= 2 AD C . 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. OUTPUT: Exp.No:4 Date: C programs for evaluating the equations : v=u+ at;s=ut + at 2 2 ;v 2 u 2 =2 asQ= 2 AD C

Upload: others

Post on 03-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Aim:

To Design and develop C programs for evaluating the equations :

v=u+at ;s=ut+ at2

2; v2−u2=2as∧Q=√ 2 AD

C .

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.

OUTPUT:

Result:

Thus the program has been executed and the output was verified.

Exp.No:4Date:

C programs for evaluating the equations :

v=u+at ;s=ut+ at2

2; v2−u2=2as∧Q=√ 2 AD

C

Page 2: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

TWO DIGIT INTEGER IN WORD

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.

Output:

Result:

Thus the program has been executed and the output was verified.

Exp no.:5

Date:

Page 3: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

SUM OF THREE FRACTIONS

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.

OUTPUT:

Result:

Thus the program has been successfully implemented

Exp No:6

Date:

Page 4: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Arranging Objects colored VIBGYOR in possible Orders

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 ‘V’,’I’,’B’,’G’,’Y’,’O’,‘R’Step 3: for a 1to 7

Step 4: for b 1 to7

Step 5: for c1 to7 ….. for g 1 to 7

Step 6: if ( a not equal to b and a not equal to c and b not equal to c …. f not equal to g)

Display str[a],str[b],str[c]…str[g]

Step 7: Stop.

OUTPUT:

VIBGYORVIBGYROVIBGORYVIBGRYOVIBGOYR..........Count : 5040

Result:

Thus the program has been successfully implemented

Exp.no: 7Date:

Page 5: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

PASCAL’S TRIANGLE USING RECURSIVE FUNCTION

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 I0 to line

for j0 to line-i-1

Write <space>

for j0 to i

write ( fact(i) / (fact(j)*fact(i - j))

End

fact(n)

begin

if (n equals 0) or (n equals 1)

return 1

else

return n*fact(n-1)

end

OUTPUT:

Result:

Exp.no: 8Date:

Page 6: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Thus the program has been successfully implemented

2D TRANSFORMATIONS: TRANSLATION, SCALING AND ROTATION.

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

Exp No.:9Date:

Page 7: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

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

Output:

Translation:

Page 8: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Scaling:

Rotation:

Page 9: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Result:

Thus the program has been successfully implemented.

STUDENTS RECORD USING ARRAY OF STRUCTURES

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 5: Read a record

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 9: Read a record

Step 10 : If record contains the required gender,

Display the record details of student

Step 11: Stop.

Exp.no:10Date:

Page 10: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

OUTPUT:

Result:

Thus the program has been successfully implemented

Page 11: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

POLYNOMIAL ADDITION,SUBTRACTION,MULTIPLICATION

USING SINGLY LINKED LIST

Aim:

To design and develop a modular program in C for performing addition, subtraction and multiplication operations on two nth 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.

OUTPUT:Create 1st expressionEnter Coeff:5Enter Pow:2Continue adding more terms to the polynomial list?(Y = 1/N = 0): 1Enter Coeff:2Enter Pow:1Continue adding more terms to the polynomial list?(Y = 1/N = 0): 1Enter Coeff:3Enter Pow:0Continue adding more terms to the polynomial list?(Y = 1/N = 0): 0Stored the 1st expressionThe polynomial expression is:5x^2 + 2x^1 + 3x^0

Create 2nd expressionEnter Coeff:4Enter Pow:2Continue adding more terms to the polynomial list?(Y = 1/N = 0): 1

Exp.no:11Date:

Page 12: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Enter Coeff:5Enter Pow:1Continue adding more terms to the polynomial list?(Y = 1/N = 0): 1Enter Coeff:9Enter Pow:0Continue adding more terms to the polynomial list?(Y = 1/N = 0):0Stored the 2nd expressionThe polynomial expression is:4x^2 + 5x^1 + 9x^0

Addition CompleteThe polynomial expression is:9x^2 + 7x^1 + 12x^0

Subtraction CompleteThe polynomial expression is:1x^2 + -3x^1 + -6x^0

Multiplication CompleteThe polynomial expression is:20x^4 + 10x^2 + 27x^0Add two more expressions? (Y = 1/N = 0): 0Press any key to continue . . .

Result:

Thus the program has been successfully implemented

Page 13: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

GENERATION OF FIBONACCI SERIES USING RECURSIVE FUNCTION

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

OUTPUT:

Result:

Thus the program has been successfully implemented for generating Fibonacci series

ExpNo:12Date:

Page 14: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

MERGING THREE TEXT FILES BASED ON A PRIMARY KEY

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.OUTPUT:

Exp.No: 13Date:

Page 15: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

Result: Thus, designing and developing 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 was successfully executed and implemented.

Page 16: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

FILTERING THE RECORDS OF BINARY FILE BASED ON THE RANGE OF PRIMARY KEY VALUES

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.

OUTPUT:

Result:Thus, designing and developing a modular program in C for filtering the records of

binary file given the range of primary key values was successfully executed and

implemented.

Exp no.: 14Date:

Page 17: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

BILLING SYSTEM FOR SARAVANA STORES

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.

Exp No: 15Date:

Page 18: socovtu.files.wordpress.com  · Web view11/3/2017  · To Design and develop a program to display a two digit integer in word. Algorithm: Step 1:Start. Step 2:Read the values of

OUTPUT:

Result: Thus, the C program for designing and developing a Checkout Billing System for

Saravana Stores was successfully executed and implemented.