Experiment - 1: Aim: To Determine The Nature of Roots of A Quadratic Equation, Its Input Is Triple of Positive
Experiment - 1: Aim: To Determine The Nature of Roots of A Quadratic Equation, Its Input Is Triple of Positive
Aim: To determine the nature of roots of a quadratic equation, its input is triple of positive
integers (say x,y,z) and values may be of from interval [1,100]. The output may be one of the
following: [Not a quadratic equation, Imaginary roots, equal roots].Perform boundary value
analysis.
Theory: Experience shows that test cases that are close to the boundary condition have
higher chances of detecting an error. Here, boundary condition means an input value maybe
just below the boundary or just above the boundary.
For a program of n variables, the boundary value analysis yields 4n+1 test cases.
Program:
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main()
{
int a, b, c, d, validinput = 0;
float root1, root2, D;
root1 = root2 = 0.0;
printf("Enter the value of a: ");
scanf("%d", &a);
printf("Enter the value of b: ");
scanf("%d", &b);
printf("Enter the value of c: ");
scanf("%d", &c);
if ((a >= 0) && (b >= 0) && (c >= 0) && (a <= 100) && (b <= 100) && (c <= 100))
{
validinput = 1;
if (a = = 0)
{
validinput = -1;
}
}
if (validinput = = 1)
{
d = (b * b) - (4 * a * c);
if (d = = 0)
{
root1 = (float)(-b) / (2 * a);
root1 *= -1;
printf("\nThe roots are equal and r1=r2=%f", root1);
}
else if (d > 0)
{
root1 = (float)(-b + sqrt(d)) / (2 * a);
root2 = (float)(-b - sqrt(d)) / (2 * a);
root1 *= -1;
root2 *= -1;
1
printf("\nThe roots are real and r1=%f and r2=%f", root1, root2);
}
else
{
root1 = (float)-b / (2 * a);
root2 = (float)sqrt(-d) / (2 * a);
printf("\nThe roots are imaginary and are r1=%f and r2=%f", root1,
root2);
}
}
else if (validinput == -1)
{
printf("\nNot a quadratic equation");
}
else
{
printf("\nThe input belong to an invalid range");
}
return 1;
}
2
Experiment-2
Aim: To determine the type of triangle. The input is a triple of positive integer(say x,y,z) and
the value maybe from interval [1,100]. The program output maybe one of the following:
Scalene, Isosceles, Equilateral or not a triangle. Perform Boundary Value Analysis.
Theory: Experience shows that the test cases that are close to boundary condition have a
higher chance of detecting an error. Here the boundary condition means, an input value may
be on the boundary , just below the boundary or just above it.
For the program of n variables, boundary value analysis yield 4n+1 test cases.
Program:
#include <stdio.h>
#include<conio.h>
int main()
{
int a,b,c, validInput=0;
printf("Enter side values:");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if((a>0)&&(a<=100) && (b>0)&&(b<=100) && (c>0)&&(c<=100))
{
if((a+b)>c && (c+b)>a && (a+c)>b )
{
validInput=1;
}
}
else
{
validInput=-1;
}
if(validInput==1)
{
if((a==b)&&(b==c))
{
printf("The triangle is Equilateral");
}
else if ((a==b)||(b==c)||(a==c))
{
printf("The triangle is isoceles");
}
else
{
printf("The triangle is scalene");
}
}
else
{
3
printf("The input belongs to an invalid range");
}
return 0;
}
4
Experiment – 3
Aim: To determine the nature of roots of a quadratic equations, its input is triple of +ve
integers (say x,y,z) and values may be from interval[1,100] the program output may have one
of the following:-[Not a Quadratic equations, Real roots, Imaginary roots, Equal
roots].Perform robust case testing on the problem.
Theory: It is an extension of boundary value analysis. Here we would like to see what
happen when the extreme value are exceeded with a value slightly greater than maximum and
a value slightly less than minimum. It means we want to go outside the legitimate boundary
of input domain. Thus extended form of boundary value analysis is called robust testing.
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int a, b, c, validinput=0, d;
double D;
printf(“Enter the ‘a’ value”);
scanf(“%d”, &a);
printf(“Enter the ‘b’ value”);
scanf(“%d”, &b);
printf(“Enter the ‘c’ value”);
scanf(“%d”, &c);
if (a>=0 && a<=100 && b>=0 && b<=100 && c>=0 && c<=100)
{
validinput=1;
if(a==0)
validinput=-1;
}
}
if (validinput==1)
{
d = b*b – 4*a*c;
if (d==0)
printf (“The roots are equal & are r1 = r2 = %f\n”, -b/(2*a));
}
else if (d>0) {
D = sqrt(d);
printf(“The root are real and r1=%f and r2=%f\n”, (-b-D)/(2*a), (-b+D)/(2*a));
}
else {
D = sqrt(-d)/(2*a);
printf (“The roots are imaginary and are r1=(%f,%f) and r2=(%f,%f)\n”, -
b/(2*a), D, -b/(2*a), -D);
}
}
5
else if (validinput==-1) {
printf (“The value do not constitute a quadratic equation”);
}
else {
printf (“The input belong to invalid range”);
}
getch();
return 1;
}
6
Experiment – 4
Aim: To determine the type of triangle. Its input is triple of +ve integers (say x,y,z) and the
values may be from interval[1,100].The program output may be one of the following
[Scalene, Isosceles, Equilateral, Not a Triangle].Perform robust case testing on the problem.
Theory: It is an extension of boundary value analysis, here we should like to see that happen
when the extreme value are exceeded with a value slightly greater than the maximum and a
value slightly less than minimum. It mean, we want to go outside legitimate boundary of
input domain. This extended form of boundary value analysis is called robust testing.
Program:
#include<stdio.h>
#include<conio.h>
int main(){
int a,b,c,valid_input=0;
printf("Enter the sides of triangle:");
scanf("%d %d %d",&a,&b,&c);
if((a>0) && (a<=100) && (b>0) && (b<=100) && (c>0) && (c<=100)){
if( ((a+b)>c) && ((b+c)>a) && ((c+a)>b) ){
valid_input = 1;
}
}
else {
valid_input = -1;
if(valid_input ==1){
if((a==b)&& (b==c)){
printf("The triangle is equilateral");
}
else if((a==b)||(b==c)||(c==a)){
printf("The triangle is scalene");}
}
else if(valid_input==0){
printf("The value do not constitute a triangle");
}
else {
printf("The input belong to valid range");
}
}
getch();
return 0;
}
7
Experiment-5
Aim: To determine the area of circle, rectangle, square and triangle by performing
equivalence clan testing.
Theory: In this technique, input and output domain is divided into finite number of
equivalences classes. Then we select one representative of each class and test our program
against it. The system herein is treated as a black box.
Program:
#include<stdio.h>
#include <stdlib.h>
#include<conio.h>
int main() {
int ch; char c;
float a,h,b;
j: prinf("\nEnter your choice: )";
printf( "\n1. Triangle");
printf( "\n2. Square");
printf( "\n3. Rectangle");
printf( "\n4. Circle");
printf( "\n5. Exit\n");
scanf("%d",ch) ;
switch(ch){
case 1: bt: printf( "\nEnter the base of triangle (1-200): ");
scanf("%d",b);
if((b<=0)||(b>200)){
printf( "\nInvalid entry for base\n");
goto bt;
}
ht: printf( "\nEnter the height of triangle (1-200): ");
scanf("%d",h);
if((h<=0)||(h>200)){
printf( "\nInvalid entry for height\n");
goto ht;
}
a= 0.5*b*h;
printf( "\nArea of triangle is: %d",a);
printf( "\nWant to enter more?(y/n): ");
scanf("%c",c);
if((c=='y') || (c== 'Y'))
goto j;
break;
case 2: s: printf( "\nEnter the side of square (1-200): ";
scanf("%d",b);
if((b<=0)||(b>200)){
printf( "\nInvalid entry for side\n";
goto s;
}
8
a= b*b;
printf( "\nArea of square is: %d",a);
printf( "\nWant to enter more?(y/n): ");
scanf("%c",c);
if((c=='y') || (c== 'Y'))
goto j;
break;
case 3: br: printf( "\nEnter the base of rectangle (1-200): ");
scanf("%d",b);
if((b<=0)||(b>200)){
printf( "\nInvalid entry for length\n");
goto br;
}
hr: printf( "\nEnter the length of rectangle (1-200): ");
scanf("%d",h);
if((h<=0)||(h>200)){
printf( "\nInvalid entry for height\n");
goto hr;
}
a= b*h;
printf( "\nArea of rectangle is: %d",a);
printf( "\nWant to enter more?(y/n): ");
scanf("%c",c);
if((c=='y') || (c== 'Y'))
goto j;
break;
case 4: rc: printf( "\nEnter the radius of circle (1-200): ");
scanf("%d",b);
if((b<=0)||(b>200)){
printf( "\nInvalid entry for side\n");
goto rc;
}
a= 3.14*b*b;
printf( "\nArea of circle is: %d",a);
printf( "\nWant to enter more?(y/n): ");
scanf("%c",c);
if((c=='y') || (c== 'Y'))
goto j;
break;
case 5: exit(0);
break;
default: printf( "\nInvalid entry\n");
}
return 0;
}
9
Experiment -6
Theory: Decision table is used for testing system for which the specification is to form of
rules or cause effect combination in a decision table. The output are listed in a column, with
the output in the same column below the input program.
Program:
#include<conio.h>
#include<stdio.h>
int main()
{
int days,month,year,validate=0;
printf(“Enter the date value“);
scanf(“%d” ,&day);
scanf(“%d”, &month);
scanf(“%d”, &year);
if(year>=1900 && year<=2025)
{
if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 ||
month==12){
if(day==1 && day<=31){
validate = 1;
}
else{
validate = 0
}
}
elseif(month ==2){
int rval = 0;
if(year%4 == 0)
{
nal = 1;
if((year%100)==0 && (year%400)!=0){
nal = 0;
}
}
If(rval ==1 && (day>=1 && day<=29)){
validate = 1;
}
elseif(day>=1 && day<=28){
validate = 1;
}
else{
validate=0;
}
10
}
elseif((month>=1 && month<=12) && (day>=1 && day<=30)){
validate =1;
}
}
}
If(rval ==1)
{
day = 29;
month--;
printf(“The next date is %d%d%d%d”, day,month,year);
}
else{
print(“The enter date(%d%d%d%d) is invalid”, day,month,year);
}
getch();
return 0;
}
11
Experiment – 7
Aim: To determine the values of x raise to power y and design test cases by performing
decision table based testing on it.
Theory: Decision Table testing is used for testing system for which the specification table
the form of rules or cause effect combination.
Program:
#include<stdio.h>
#include<math.h>
int main()
{
int a,b;
float c;
char ch;
do{
printf("\nCalculate a to power b\n");
printf("\nEnter the value for a: ");
scanf("%d", &a);
printf("Enter the value for b: ");
scanf("%d", &b);
c = pow(a,b);
printf("Result C = %f\n", c);
printf("Want to enter again? (y/n): ");
scanf("%s", &ch);}
while((ch=='y')||(ch=='Y'));
return 0;
12
Experiment-8
Aim: To determine the type of triangle. The input is a triple of positive integer(say x,y,z) and
the value maybe from interval [1,100]. The program output maybe one of the following:
Scalene, Isosceles, Equilateral or not a triangle. Perform Decision Table Testing.
Theory: Decision Table Testing is used for those system for which the specification table
form the rules or cause-effect combination.
Program:
#include <stdio.h>
#include<conio.h>
int main()
{
int a,b,c, validInput=0;
printf("Enter side values:");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if((a>0)&&(a<=100) && (b>0)&&(b<=100) && (c>0)&&(c<=100))
{
if((a+b)>c && (c+b)>a && (a+c)>b )
{
validInput=1;
}
if(validInput==1)
{
if((a==b)&&(b==c))
{
printf("The triangle is Equilateral");
}
else if ((a==b)||(b==c)||(a==c))
{
printf("The triangle is isoceles");
}
else
{
printf("The triangle is scalene");
}
}
else
{
printf("The input belongs to an invalid range");
}
}
return 0;}
13
Experiment - 9
Aim: To determine three sides of a triangle. Its input will be greater than 0 and smaller than
100.Show that they form scalene, isosceles or equilateral triangle. Design a test case by using
cause effect graphing testing technique.
Theory: Path Graph - DD is a directed graph in which node are sequence of statements and
edges represent control flow between nodes.
Program:
#include<stdio.h>
#include<conio.h>
int main(){
int a,b,c,valid_input=0;
printf("Enter the sides of triangle:");
scanf("%d %d %d",&a,&b,&c);
if((a>0) && (a<=100) && (b>0) && (b<=100) && (c>0) && (c<=100)){
if( ((a+b)>c) && ((b+c)>a) && ((c+a)>b) ){
valid_input = 1;
}
if((a==b) && (b==c)){
printf("The triangle is equilateral");
}else if((a==b) || (b==c) || (c==a)){
printf("The triangle is isosceles");
}else{
printf("The triangle is scalene");
}
}else{
printf("The input belongs to invalid range");
}
getch();
return 0;
}
14
Experiment – 10
Aim: To design the test cases by performing path testing on to determine the value of X raise
to V and perform and deduce the following.
● Flow graph
● DD path graph
● Independent path
● Cyclometric path
Theory: Flow Graph: The control flow of program can be analysed using a graphical
representation known as flow graph. The flow graph is a directed graph in which nodes are
either statement or fragment of a statement.
DD Path Graph: It is a directed graph in which nodes are sequence of statement and edge
represent control flow between nodes.
Independent Path: It is any path through the DD path graph that introduce at least a new set of
processing statement at new condition.
Program:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int a, b;
float c;
char ch;
z : printf("Calculate a to power b");
printf("Enter the value for a and b");
scanf("%d",&a);
scanf("%d",&b);
c=pow(a,b);
printf("Result %f",c);
printf("Want to enter again? (y/n)");
scanf("%c",&ch);
if((ch=='y')||(ch=='y'))
goto z;
}
15
Experiment-11
Aim: Compute the total salary of an employee given his/her basic salary. The state is given
below
HRA=30% of basic
DA=80% of basic
MA=Rs 100
TA=Rs 700
ITAX=Rs 700
PF=Rs 780
Draw Path graph & find its V(G) by all the three methods.
Theory:DD Path is a directed graph in which nodes are sequence of statement and edge
represent control flow between nodes.
Program:
#include<stdio>
#include<conio.h>
void main()
{
clrscr();
printf("Enter the basic salary of the employee");
float bs;
scanf("%d",&bs);
int hra,da,ma=100,itax=700,pf=780,tax=800;
hra=0.3*bs;
da=0.8*bs;
printf("\nMain allowance Rs",&hra);
printf("\nDarkness allowance Rs",&da);
printf("\nMedical allowance Rs",&ma);
printf("\nIncome tax Rs",&itax);
printf("\nProvided fund Rs",&pf);
float netsal;
netsal=bs+hra+da+ma-(itax+pf);
printf("\nThe net salary of employee",&netsal);
getch();
}
16
Experiment – 12
Aim: To determine the three sides of a triangle, its input is a positive integer, greater than or
equal to 100. Show that they form a scalene, isosceles or equilateral triangle. Draw DD path
graph.
Program:
#include<stdio.h>
#include<conio.h>
int main() {
int a, b, c, validinput=0;
printf(“Enter side ‘a’ value”);
scanf(“%d”, &a);
printf(“Enter side ‘b’ value”);
scanf(“%d”, &b);
printf(“Enter side ‘c’ value”);
scanf(“%d”, &c);
if ((a>0) && (a<=100) && (b>0) && (b<=100) && (c>0) && (c<=100)) {
if (((a+b)>c) && ((c+a)>b)) && ((b+c)>a)) {
Validinput = 1;
}
} else {
Validinput = 0;
}
if (validinput == 1){
if ((a==b) && (b==c)) {
printf(“The triangle is equilateral”);
} else if ((a==b) || (b==c) || (c==a)) {
printf(“The triangle is isosceles”);
} else {
printf(“The triangle is scalene”);
}
} else if (validinput == 0) {
printf(“The value doesnot constitute a triangle”);
} else {
printf(“The input belong to invalid range”);
}
getch();
return 0;
}
17
EXPERIMENT – 13
Aim: To develop a program to read the marks of 10 students in five subjects. Find their
averages and allot them grades. Draw its graph matrix and find its V(G).
Theory: A graph matrix is a square matrix with one row and one column for every node in
the graph. The size of the matrix is equal to the number of node in the flow graph.
Program:
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{ char same[20];
float marks[5], total, avg;
char grade;
}s[10];
void main()
{ clrscr();
int i;
for(i=1;i<=10;i++)
{ printf(”Enter the name of the student%d”,i);
gets(s[i].sname);
for(int j=0;j<5;j++)
{ printf(”Enrter the marks in subject%d”,j);
scanf(s[i].marks[j]);
}
for(j=0;j<s;j++;j++)
{ s[i].total=s[i].total+s[i].marks[j];
}
s[i].avg=s[i].total/5;
printf(”The average of student%d is”,i,s[i].avg);
if(s[i].avg>90.0)
s[i].grade=”A+”;
else if((s[i].avg<90.0&&(s[i].avg>=85.0))
s[i].grade=”A”;
else if((s[i].avg<85.0)&&(s[i].avg>=80.0))
s[i].grade=”B”;
else if((s[i].avg<80.0)&&(s[i].avg>=70.0))
s[i].grade=”C”;
else
s[i].grade=”D”;
printf(”The grade of student%d is”,i,s[i].grade);
}
getch();
}
18
Experiment – 14
Aim: To determine the nature of roots of a quadratic equations, its input is triple of +ve
integers (say x,y,z) and values may be from interval[1,100] the program output may have one
of the following:-[Not a Quadratic equations, Real roots, Imaginary roots, Equal
roots].Perform data flow testing on it.
Theory: Data flow testing is other form of structural testing. It has nothing to do with the
data diagram. Here we concentrate on the usage of variable and the focus point.
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int a,b,c,validinput=0,d;
float D;
printf("enter the 'a' value: ");
scanf("%d",&a);
printf("enter the 'b' value: ");
scanf("%d",&b);
printf("enter the 'c' value: ");
scanf("%d",&c);
if((a>=0)&&(a<=100)&&(b>=0)&&(b<=100)&&(c>=0)&&(c<=100))
{
validinput=1;
if(a==0)
{
validinput=-1;
}
}
if(validinput==1)
{
d=b*b-4*a*c;
if(d==0)
{
printf("the root are equal and r1=r2=%f\n", -b/(2*a));
}
else if(d>0)
{ D=sqrt(d);
printf("the root are real and are r1=%f & r2=%f\n",(-b-D)/(2*a),(-b+D)/(2*a));
}
else
{
d=-1*d;
D=sqrt(d)/(2*a);
printf("%d",D);
19
printf("the root are imaginary and are r1=(%d,%.1fi) and r2=(%d,%.1fi)\n",-
b/(2*a),D,-b/(2*a),-D);
}
}
else if(validinput==-1)
{
printf("the value do not form a quadratic equation");
}
else
{
printf("the input belong to a invalid range"); }
getch();
return 0;
}
20
Experiment – 15
Tool 1
DRAGON-A static and dynamic tool for open MP
Case study
Creating and testing open MP program with Dragon .A basic strategy for parallelising a code
using Dragon is as follows:
Compile the application and run it.Involve dragon and use its menus to locate important
functions or procedures in the code. Inspect the call graph to find the highest level
opportunity for exploiting parallelism and use the control flow graphs to find loop nest, data
dependence information can then be requested for loans to determine whether they can be
parallelised. This will give details of any variable accesses that may prevent parallelism, so
that opportunities for manual modification maybe explored. The call graph and feedback
information are stored in dragon’s database. It is also easy to obtain data dependence
information. In addition data dependence analysis is related to individual loop nests. Another
problem is that the burden of finding out which variable should be shared remains with the
user.
Tool 2
HD LOAD RUNNER
Case study
Load runner testing result analysis – consider the client side application for an automated
teller machine. Although each client is connected to server hundreds of aim maybe open to
the public. During peak times the load maybe much higher than the normal.in order to test
such situations, a load runner can be used to stimulate a large number of users assessing the
server simultaneously. Another activities are defined and they are repeatable. After
debugging of problem in the application, managers can check whether problem persists by
reproducing the same situation, with same type of user information.it allows users editing the
script to replace recorded values in a script with parameters which is called parameterisation
and is often used when application needs unique data (such as user names), data
dependency(such as passwords) , data cache.
21
Experiment- 16
Aim: To develop a program for finding factorial of a number and computing different
coverage (statement, condition, function) achieved during the execution of various test cases.
Theory: Code coverage testing involves designing and executing test cases and finding out
the percentage of code that is covered by testing.
Program:
#include <stdio.h>
long factorial(int);
int main()
{
int number;
char ch;
long fact = 1;
l: printf("Enter a number to calculate its factorial\n");
scanf("%d", &number);
printf("%d! = %ld\n", number, factorial(number));
printf("Do you want to enter more (y/n)");
scanf("%c", &ch);
if (ch=='y'|| ch=='Y'){
goto l; }
else{
printf("\nThankyou");
}
return 0;
}
long factorial(int n)
{
int c;
long result = 1;
for (c = 1; c <= n; c++)
result = result * c;
return result;
}
22