×

Close

Type:
**Practical**Institute:
**
Anna university
**Specialization:
**Information Technology Engineering**Offline Downloads:
**2**Views:
**550**Uploaded:
**4 months ago**

Touch here to read

Page-1

- Introduction and Content - ( 1 - 2 )
- C Programs using Conditional and Control Statements - ( 3 - 6 )
- C Programs using Arrays, Strings and Pointers and Functions - ( 7 - 17 )
- File Handling and Structures in C - ( 18 - 22 )
- Creation of Linked List – Manipulation of records in a Linked List - ( 23 - 28 )
- Stacks and Queue - ( 29 - 51 )
- Searching Techniques - ( 52 - 55 )
- Sorting Techniques - ( 56 - 61 )

Experiment:

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

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

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

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

## Leave your Comments