WordPress.com



Exp.No:4Date:C programs for evaluating the equations : v=u+at; s=ut+at22 ; v2-u2=2as and Q= 2ADCAim:To Design and develop C programs for evaluating the equations : v=u+at;s=ut+at22 ; v2-u2=2as and Q= 2ADC .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*sStep 7: Check l is equal to p.Step7: Read the value of A,D,CStep8: 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.:5Date:TWO DIGIT INTEGER IN WORDAim: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:6Date:SUM OF THREE FRACTIONSAim: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 resDStep 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: 7Date:Arranging Objects colored VIBGYOR in possible OrdersAim: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 7Step 4: for b 1 to7Step 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 : 5040Result:Thus the program has been successfully implemented Exp.no: 8Date:PASCAL’S TRIANGLE USING RECURSIVE FUNCTIONAim: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-1Write <space>for j0 to iwrite ( fact(i) / (fact(j)*fact(i - j))Endfact(n)beginif (n equals 0) or (n equals 1)return 1elsereturn n*fact(n-1)endOUTPUT:Result:Thus the program has been successfully implemented Exp No.:9Date: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, rotationStep 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 rectangleStep 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:Scaling:Rotation:Result:Thus the program has been successfully implemented.Exp.no:10Date:STUDENTS RECORD USING ARRAY OF STRUCTURESAim: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 genderStep 3: Get the record details and store as array of structuresStep 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 processedStep 8: Read the search field (gender g) for clustering the recordsStep 9: Read a record Step 10 : If record contains the required gender, Display the record details of studentStep 11: Stop.OUTPUT:Result:Thus the program has been successfully implemented Exp.no:11Date:POLYNOMIAL ADDITION,SUBTRACTION,MULTIPLICATION USING SINGLY LINKED LISTAim: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^0Create 2nd expressionEnter Coeff:4Enter Pow:2Continue adding more terms to the polynomial list?(Y = 1/N = 0): 1Enter 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^0Addition CompleteThe polynomial expression is:9x^2 + 7x^1 + 12x^0Subtraction CompleteThe polynomial expression is:1x^2 + -3x^1 + -6x^0Multiplication 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 ExpNo:12Date:GENERATION OF FIBONACCI SERIES USING RECURSIVE FUNCTIONAim: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 functionAlgorithm: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 0Step 5: Call function fib (i) and print the resultStep 5: StopOUTPUT:Result:Thus the program has been successfully implemented for generating Fibonacci seriesExp.No: 13Date:MERGING THREE TEXT FILES BASED ON A PRIMARY KEYAim: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: 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.Exp no.: 14Date:FILTERING THE RECORDS OF BINARY FILE BASED ON THE RANGE OF PRIMARY KEY VALUESAim: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: 15Date:BILLING SYSTEM FOR SARAVANA STORESAim: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, priceStep 7: Compute totalBill = totalBill+priceStep 7: Repeat the Step 4 to Step 7, until there are records in the transaction file.Step 8: Display total bill.Step 9: Stop.OUTPUT:Result: Thus, the C program for designing and developing a Checkout Billing System for Saravana Stores was successfully executed and implemented. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download