×
If you can dream it, you can do it.
--Your friends at LectureNotes

# Lab Manuals for Data Structure using C - DS By ANNA SUPERKINGS

• Data Structure using C - DS
• Practical
• Anna university - ACEW
• Information Technology Engineering
• 8 Experiments
• 757 Views
• Uploaded 1 year ago
Touch here to read
Page-1

#### Lab Manuals for Data Structure using C - DS By ANNA SUPERKINGS

Experiment: / 61

0 User(s)

#### Text from page-1

Bachelor of Engineering First Year II SEMESTER CS6212 – PROGRAMMING AND DATA STRUCTURES LABORATORY – I LAB MANUAL DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Page 1

#### Text from page-2

CS6212 – PROGRAMMING AND DATA STRUCTURES LABORATORY - I LTPC0032 OBJECTIVES: • To introduce the concepts of structured Programming language. • To introduce the concepts of pointers and files • To introduce the concepts of primitive Data Structures. 1. C Programs using Conditional and Control Statements 2. C Programs using Arrays, Strings and Pointers and Functions 3. Representation of records using Structures in C – Creation of Linked List – Manipulation of records in a Linked List 4. File Handling in C – Sequential access – Random Access 5. Operations on a Stack and Queue – infix to postfix – simple expression evaluation using stacks - Linked Stack Implementation – Linked Queue Implementation 6. Implementation of Sorting algorithms 7. Implementation of Linear search and Binary Search. TOTAL: 45 PERIODS Dhaanish Ahmed Institute of Technology Page 2

#### Text from page-3

Ex. No.: 1.a ROOTS OF QUADRATIC EQUATIONS Aim: To write a C program for finding the roots of a given quadratic equation using conditional control statements. Algorithm: 1. 2. 3. 4. 5. 6. 7. Start the program. Declare the variables and read the coefficients and constants. Find the determinant. If it is greater than zero, print the roots are real and distinct and find the roots. If it is less than zero, print the roots are imaginary. If it is equal to zero, print the roots are real and equal and find the roots. Stop the program. Dhaanish Ahmed Institute of Technology Page 3

#### Text from page-4

Program: /*Roots of a Quadratic Equation*/ #include <stdio.h> #include <math.h> int main() { float a, b, c, determinant, r1,r2, real, imag; printf("Enter coefficients a, b and c: "); scanf("%f%f%f",&a,&b,&c); determinant=b*b-4*a*c; if (determinant>0) { r1= (-b+sqrt(determinant))/(2*a); r2= (-b-sqrt(determinant))/(2*a); printf("Roots are: %.2f and %.2f",r1 , r2); } else if (determinant==0) { r1 = r2 = -b/(2*a); printf("Roots are: %.2f and %.2f", r1, r2); } else { real= -b/(2*a); imag = sqrt(-determinant)/(2*a); printf("Roots are: %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag); } return 0; } Output: Enter coefficients a, b and c: 2.3 4 5.6 Roots are: -0.87+1.30i and -0.87-1.30i Dhaanish Ahmed Institute of Technology Page 4