Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
29 views
3 pages
LAB Mannual - POP
Pop lab manual
Uploaded by
Durai M
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download
Save
Save LAB Mannual_POP For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
29 views
3 pages
LAB Mannual - POP
Pop lab manual
Uploaded by
Durai M
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save LAB Mannual_POP For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save LAB Mannual_POP For Later
You are on page 1
/ 3
Search
Fullscreen
Lab Program-1
Compute the roots of a quadratic equation by accepting the coefficients.
Print appropriate messages.
#include <stdio.h>
#include <math.h>
int main()
{
double a, b, c;
double discriminant, root1, root2, realPart, imaginaryPart;
// Input coefficients
printf("Enter coefficient a: ");
scanf("%lf", &a);
printf("Enter coefficient b: ");
scanf("%lf", &b);
printf("Enter coefficient c: ");
scanf("%lf", &c);
// Check if the equation is quadratic
if (a == 0)
{
printf("The value of 'a' cannot be zero. This is not a quadratic
equation.\n");
return 0;
}
// Calculate the discriminant
discriminant = b * b - 4 * a * c;
// Check the nature of the roots
if (discriminant > 0)
{
// Two distinct real roots
root1 = (-b + sqrt(discriminant)) / (2 * a);
root2 = (-b - sqrt(discriminant)) / (2 * a);
printf("The equation has two distinct real roots:\n");
printf("Root 1: %.2f\n", root1);
printf("Root 2: %.2f\n", root2);
}
else if (discriminant == 0)
{
// One real root (repeated)
root1 = -b / (2 * a);
printf("The equation has one real root (repeated):\n");
printf("Root: %.2f\n", root1);
}
else
{
// Two complex roots
realPart = -b / (2 * a);
imaginaryPart = sqrt(-discriminant) / (2 * a);
printf("The equation has two complex roots:\n");
printf("Root 1: %.2f + %.2fi\n", realPart, imaginaryPart);
printf("Root 2: %.2f - %.2fi\n", realPart, imaginaryPart);
}
return 0;
}
OUTPUT:
1) Enter coefficient a: 1
Enter coefficient b: -7
Enter coefficient c: 10
The equation has two distinct real roots:
Root 1: 5.00
Root 2: 2.00
2)Enter coefficient a: 1
Enter coefficient b: 2
Enter coefficient c: 5
The equation has two complex roots:
Root 1: -1.00 + 2.00i
Root 2: -1.00 - 2.00i
3)Enter coefficient a: 1
Enter coefficient b: 2
Enter coefficient c: 1
The equation has one real root (repeated):
Root: -1.00
You might also like
C Lab Programs Vtu 2022 Scheme
PDF
No ratings yet
C Lab Programs Vtu 2022 Scheme
4 pages
C Programs
PDF
100% (1)
C Programs
101 pages
RU-CSE-C Programming Lab Manual
PDF
No ratings yet
RU-CSE-C Programming Lab Manual
40 pages
Anshul Yadavcbnst
PDF
No ratings yet
Anshul Yadavcbnst
54 pages
Lesson 3: Selection: If, ?, Switch
PDF
No ratings yet
Lesson 3: Selection: If, ?, Switch
17 pages
Ie1005-W3t2 ZX
PDF
No ratings yet
Ie1005-W3t2 ZX
13 pages
C++ Program To Find All Roots of A Quadratic Equation
PDF
No ratings yet
C++ Program To Find All Roots of A Quadratic Equation
7 pages
C Program To Find All Roots of A Quadratic Equation Using Switch Case
PDF
No ratings yet
C Program To Find All Roots of A Quadratic Equation Using Switch Case
2 pages
CBNST 2
PDF
No ratings yet
CBNST 2
20 pages
C Program To Find The Sum of First N Natural Numbers
PDF
No ratings yet
C Program To Find The Sum of First N Natural Numbers
4 pages
22POP13LAB
PDF
No ratings yet
22POP13LAB
40 pages
PC Lab Manual
PDF
No ratings yet
PC Lab Manual
23 pages
Pooja
PDF
No ratings yet
Pooja
8 pages
Quadratic Calculator Team 5
PDF
No ratings yet
Quadratic Calculator Team 5
3 pages
C Programming Assignment 1
PDF
No ratings yet
C Programming Assignment 1
6 pages
CBNST (Lab)
PDF
No ratings yet
CBNST (Lab)
7 pages
TP 2 Answers
PDF
No ratings yet
TP 2 Answers
17 pages
Lab V
PDF
No ratings yet
Lab V
3 pages
Upperlower I Quad
PDF
No ratings yet
Upperlower I Quad
3 pages
Quadratic Roots
PDF
No ratings yet
Quadratic Roots
9 pages
Practi
PDF
No ratings yet
Practi
2 pages
C++quadratic Program
PDF
No ratings yet
C++quadratic Program
2 pages
CBNST
PDF
No ratings yet
CBNST
12 pages
Objective: 1. Write A Program in C Language To Find The Roots of Given Algebraic Equations Using Bisection Method
PDF
No ratings yet
Objective: 1. Write A Program in C Language To Find The Roots of Given Algebraic Equations Using Bisection Method
12 pages
Biggest Among Three Numbers Program
PDF
No ratings yet
Biggest Among Three Numbers Program
6 pages
Sl. No. Experiments/Programs Cos
PDF
No ratings yet
Sl. No. Experiments/Programs Cos
17 pages
D 27ass 01
PDF
No ratings yet
D 27ass 01
13 pages
C Programming Laboratory (13MCA16) : 1 Prepared by Prof. Suma M.G., Asst. Professor - RNSIT, Bangalore
PDF
No ratings yet
C Programming Laboratory (13MCA16) : 1 Prepared by Prof. Suma M.G., Asst. Professor - RNSIT, Bangalore
34 pages
Practical No.1
PDF
No ratings yet
Practical No.1
3 pages
#Include Using Namespace Int
PDF
No ratings yet
#Include Using Namespace Int
2 pages
C Program To Find All Roots of A Quadratic Equation
PDF
No ratings yet
C Program To Find All Roots of A Quadratic Equation
2 pages
Arpita PRP
PDF
No ratings yet
Arpita PRP
31 pages
Assignment Number Problem Statement: Example: If P and Q Are The Roots of A Equation 5x
PDF
No ratings yet
Assignment Number Problem Statement: Example: If P and Q Are The Roots of A Equation 5x
6 pages
PRGM 2
PDF
No ratings yet
PRGM 2
2 pages
Quadratic Equation
PDF
No ratings yet
Quadratic Equation
2 pages
Numerical Methods Programming
PDF
No ratings yet
Numerical Methods Programming
9 pages
Cit212 Assignment
PDF
No ratings yet
Cit212 Assignment
3 pages
For A Quadratic Equation Ax2
PDF
No ratings yet
For A Quadratic Equation Ax2
3 pages
Program To Find The Roots of A Quadratic Equation: Bhargav - CH MECH022
PDF
No ratings yet
Program To Find The Roots of A Quadratic Equation: Bhargav - CH MECH022
2 pages
Quadratic
PDF
No ratings yet
Quadratic
3 pages
C Programs
PDF
No ratings yet
C Programs
3 pages
Control Flow
PDF
No ratings yet
Control Flow
2 pages
Wa0004. 5
PDF
No ratings yet
Wa0004. 5
1 page
CBNT
PDF
No ratings yet
CBNT
29 pages
PFC - Workshop 04B: 1. Fraction Simplifier
PDF
No ratings yet
PFC - Workshop 04B: 1. Fraction Simplifier
2 pages
#Include
PDF
No ratings yet
#Include
2 pages
Untitled 1
PDF
No ratings yet
Untitled 1
1 page
Roots of Quadratic Eqn
PDF
No ratings yet
Roots of Quadratic Eqn
1 page
Pseudocode-1 - Activity 45
PDF
No ratings yet
Pseudocode-1 - Activity 45
1 page
Quadtratic Equation
PDF
No ratings yet
Quadtratic Equation
2 pages
C Experiment
PDF
No ratings yet
C Experiment
1 page
Quadratic 1
PDF
No ratings yet
Quadratic 1
2 pages
#Include #Include Int Float Float: Equation
PDF
No ratings yet
#Include #Include Int Float Float: Equation
2 pages
Week 5-C Lab Program
PDF
No ratings yet
Week 5-C Lab Program
4 pages
Quadratic Equation CPP Project
PDF
No ratings yet
Quadratic Equation CPP Project
4 pages
Task 4..... (2303166-181)
PDF
No ratings yet
Task 4..... (2303166-181)
27 pages
Simple Quadratic
PDF
No ratings yet
Simple Quadratic
1 page
Program 2
PDF
No ratings yet
Program 2
3 pages
Program 4
PDF
No ratings yet
Program 4
2 pages
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet