C program Boundary Value Analysis - Nature of roots of a quadratic equation
bva_quadratic.txt
File size: 1.21 KB
File content type: text/plain
Category: Practical Files
Subject: Software Testing and Quality Assurance
#include <stdio.h>
#define MIN 0
#define MAX 100
void test(int a, int b, int c) {
char *output = "";
if(a == 0) {
output = "Not a Quadratic Equation\n";
} else {
int d = b*b - 4*a*c;
if(d < 0) {
output = "Imaginary Roots\n";
} else if(d == 0) {
output = "Real and Equal Roots\n";
} else {
output = "Real and Distinct Roots\n";
}
}
printf("%d\t%d\t%d\t%s",a,b,c,output);
}
int main(void) {
int min, max;
printf("Enter range\n");
scanf("%d%d",&min,&max);
if(min < MIN || max > MAX) {
printf("Invalid range\n");
return 0;
}
int nominal = (min + max)/2;
int values[] = {min, min+1, nominal, max-1, max};
printf("a\tb\tc\tOutput\n");
// fix variable b,c to nominal value and change values of a
for(int i=0;i<5;i++) {
test(values[i],nominal, nominal);
}
//fix variable a,c to nominal value and change values of b
for(int i=0;i<5;i++) {
// skip the case where all three values of a,b,c are same
// since it was already included once in above loop
if(values[i] != nominal)
test(nominal, values[i], nominal);
}
// fix variable a,b to nominal values and change values of c
for(int i=0;i<5;i++) {
if(values[i] != nominal)
test(nominal, nominal, values[i]);
}
return 0;
}
STQA nature of roots program.
Last Updated: July 16, 2022
Related
IPU ECE 6th Sem Syllabus
Category: SyllabusJuly 17, 2022
BBA Ecommerce Notes PDF Unit 3
Category: NotesJuly 17, 2022
Radioactivity
Category: NotesJuly 16, 2022
IPU BBA Cost Accounting Notes Unit 3
Category: NotesJuly 17, 2022
Applied Physics 2 Quantum Mechanics Notes
Category: NotesJuly 16, 2022
Engineering Chemistry Jain Jain Book PDF
Category: eBooksJuly 16, 2022
EHVACDC unit 2 FACTS topic
Category: NotesJuly 17, 2022
Mathematics I Asymptotes
Category: NotesJuly 17, 2022
Business Laws Notes PDF Unit 4
Category: NotesJuly 17, 2022
FM Notes Unit 2 PDF
Category: NotesJuly 17, 2022