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
International Business Management Notes Unit 4
Category: NotesJuly 17, 2022
Doubly Linked List program in C
Category: Practical FilesJuly 16, 2022
Three Voltmeter Method Experiment
Category: Practical FilesJuly 16, 2022
B.L. Thareja-Basic electrical Engineering (Vol.1)
Category: eBooksJuly 16, 2022
IPU Project Management Notes PDF Unit 4
Category: NotesJuly 17, 2022
Mechanics Unit 3 and 4 HandWritten Notes
Category: NotesJuly 16, 2022
ET Notes For 1st Semester
Category: NotesJuly 16, 2022
Java Sockets
Category: NotesJuly 16, 2022
IPU BPS Notes Unit 3
Category: NotesJuly 17, 2022
Engineering Graphics Viva Questions PDF
Category: NotesJuly 16, 2022