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
Magnetic Circuits - Unit 4 - Handwritten Notes
Category: NotesJuly 16, 2022
Software Engineering Solved Paper IPU Bhavya 2016
Category: Question PapersJuly 16, 2022
Mobile Computing Notes IPU Unit 3 and 4
Category: NotesJuly 16, 2022
Electrical Technology Practical File PDF
Category: Practical FilesJuly 16, 2022
Business Ethics CSR Notes Unit 2
Category: NotesJuly 17, 2022
Java Program Read and Write to a Binary File example
Category: Practical FilesJuly 16, 2022
Renewable Energy Resources Unit 2
Category: NotesJuly 17, 2022
Services Marketing Notes Unit 1 PDF
Category: NotesJuly 17, 2022
IPU IBM Notes Unit 3
Category: NotesJuly 17, 2022
FOC Practical File Printed First Sem
Category: Practical FilesJuly 16, 2022