0% found this document useful (0 votes)
47 views

SOFTWARETESTING

This document contains 7 programming assignments to solve triangle and commission calculation problems using different testing techniques. For each assignment, the student is asked to write program code to solve the problem, derive test cases based on the specified technique (e.g. decision table testing), execute the test cases, and report the results. The techniques covered include decision table testing, boundary value analysis, equivalence class partitioning, and dataflow testing. Sample program code and blank test report tables are provided for each assignment.

Uploaded by

Darshan Bc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

SOFTWARETESTING

This document contains 7 programming assignments to solve triangle and commission calculation problems using different testing techniques. For each assignment, the student is asked to write program code to solve the problem, derive test cases based on the specified technique (e.g. decision table testing), execute the test cases, and report the results. The techniques covered include decision table testing, boundary value analysis, equivalence class partitioning, and dataflow testing. Sample program code and blank test report tables are provided for each assignment.

Uploaded by

Darshan Bc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

NAME:

USN:

SUBJECT:

INDEX

SR.NO DATE TITLE Pg.NO SIGN


DATE:……………………………..

1. Design and develop a program in a language of your choice to solve the triangle problem defined as
follows: Accept three integers which are supposed to be the three sides of a triangle and determine
if the three values represent an equilateral triangle, isosceles triangle, scalene triangle, or they do
not form a triangle at all. Derive test cases for your program based on decision-table approach,
execute the test cases and discuss the results.

PROGRAM CODE:

#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
int main()
{
int a, b, c;
clrscr();
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
if((a<b+c)&&(b<a+c)&&(c<a+b))
{
if((a==b)&&(b==c))
{
printf("Equilateral triangle");
}
else if((a!=b)&&(a!=c)&&(b!=c))
{
printf("Scalene triangle");
}
else
printf("Isosceles triangle");
}
else {
printf("triangle cannot be formed");
}
return 0;

}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:……………………………..

2. Design and develop a program in a language of your choice to solve the triangle problem defined as
follows:
Accept three integers which are supposed to be the three sides of a triangle and determine if the
three values represent an equilateral triangle, isosceles triangle, scalene triangle, or they do not
form a triangle at all. Assume that the upper limit for the size of any side is 10. Derive test cases for
your program based on boundary-value analysis, execute the test cases and discuss the results.

PROGRAM CODE:

#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
int main()
{
int a, b, c;
clrscr();
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
if((a > 10) || (b > 10) || (c > 10))
{
printf("Out of range");
exit(0);
}
if((a<b+c)&&(b<a+c)&&(c<a+b)) {
if((a==b)&&(b==c)) {
printf("Equilateral triangle");
}
else if((a!=b)&&(a!=c)&&(b!=c)) {
printf("Scalene triangle");
}
else printf("Isosceles triangle");
}
else {
printf("triangle cannot be formed");
}
return 0;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:…………………………………

3. Design and develop a program in a language of your choice to solve the triangle problem defined as
follows:
Accept three integers which are supposed to be the three sides of a triangle and determine if the
three values represent an equilateral triangle, isosceles triangle, scalene triangle, or they do not
form a triangle at all. Assume that the upper limit for the size of any side is 10. Derive test cases for
your program based on equivalence class partitioning, execute the test cases and discuss the results.

PROGRAM CODE

#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<process.h>
int main()
{
int a, b, c;
clrscr();
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
if((a > 10) || (b > 10) || (c > 10)) {
printf("Out of range");
exit(0);
}
if((a<b+c)&&(b<a+c)&&(c<a+b)) {
if((a==b)&&(b==c)) {
printf("Equilateral triangle");
}
else if((a!=b)&&(a!=c)&&(b!=c)) {
printf("Scalene triangle");
}
else printf("Isosceles triangle");
}
else {
printf("triangle cannot be formed");
}
return 0;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:……………………………………..

4. Design, develop, code and run the program in any suitable language to solve the commission
problem.
Analyze it from the perspective of dataflow testing, derive different test cases, execute these test
cases and discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
clrscr();
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70)) {
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80)) {
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90)) {
flag = 1;
}
if (flag == 1) {
printf("invalid input");
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000) {
commission = 0.10 * t_sales;
}
else if (t_sales < 1800) {
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
else {
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
printf("The total sales is %d \n The commission is %f",t_sales, commission);
return;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:……………………………………

5. Design, develop, code and run the program in any suitable language to solve the commission
problem.
Analyze it from the perspective of boundary value testing, derive different test cases, execute these
test cases and discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
clrscr();
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70)) {
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80)) {
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90)) {
flag = 1;
}
if (flag == 1) {
printf("invalid input");
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000) {
commission = 0.10 * t_sales;
}
else if (t_sales < 1800) {
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
else {
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
printf("The total sales is %d \n The commission is %f",t_sales, commission);
return;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:………………………………….

6. Design, develop, code and run the program in any suitable language to solve the commission
problem.
Analyze it from the perspective of equivalence class testing, derive different test cases, execute
these test cases and discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
clrscr();
printf("Enter the total number of locks");
scanf("%d",&locks);
if ((locks <= 0) || (locks > 70)) {
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);

if ((stocks <= 0) || (stocks > 80)) {


flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90)) {
flag = 1; } if (flag == 1) {
printf("invalid input");
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000) {
commission = 0.10 * t_sales;
}
else if (t_sales < 1800) {
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
else {
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
printf("The total sales is %d \n The commission is %f",t_sales, commission);
return 0;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:…………………………….

7. Design, develop, code and run the program in any suitable language to solve the commission
problem.
Analyze it from the perspective of decision table-based testing, derive different test cases, execute
these test cases and discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int locks, stocks, barrels, t_sales, flag = 0;
float commission;
clrscr();
printf("Enter the total number of locks");
scanf("%d",&locks); if ((locks <= 0) || (locks > 70)) {
flag = 1;
}
printf("Enter the total number of stocks");
scanf("%d",&stocks);
if ((stocks <= 0) || (stocks > 80)) {
flag = 1;
}
printf("Enter the total number of barrelss");
scanf("%d",&barrels);
if ((barrels <= 0) || (barrels > 90)) {
flag = 1;
}
if (flag == 1) {
printf("invalid input");
exit(0);
}
t_sales = (locks * 45) + (stocks * 30) + (barrels * 25);
if (t_sales <= 1000) {
commission = 0.10 * t_sales;
}
else if (t_sales < 1800) {
commission = 0.10 * 1000;
commission = commission + (0.15 * (t_sales - 1000));
}
else {
commission = 0.10 * 1000;
commission = commission + (0.15 * 800);
commission = commission + (0.20 * (t_sales - 1800));
}
printf("The total sales is %d \n The commission is %f",t_sales, commission);
return;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:………………………..

8. Design, develop, code and run the program in any suitable language to implement the binary
search algorithm.
Determine the basis paths and using them derive different test cases, execute these test cases and
discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int a[20],n,low,high,mid,key,i,flag=0;
clrscr();
printf("Enter the value of n:\n");
scanf("%d",&n);
if(n>0) {
printf("Enter %d elements in ASCENDING order\n",n);
for(i=0;i<n;i++) {
scanf("%d",&a[i]);
}
printf("Enter the key element to be searched\n");
scanf("%d",&key);
low=0;
high=n-1;
while(low<=high) {
mid=(low+high)/2;
if(a[mid]==key) {
flag=1;
break;
}
else if(a[mid]<key) {
low=mid+1;
}
else {
high=mid-1;
}
}
if(flag==1)
printf("Successful search\n Element found at Location %d\n",mid+1);
else
printf("Key Element not found\n");
}
else
printf("Wrong input");
return 0;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:………………………………..

9. Design, develop, code and run the program in any suitable language to implement the quicksort
algorithm.
Determine the basis paths and using them derive different test cases, execute these test cases and
discuss the test results. discuss the test results.

#include <stdio.h>
void swap ( int* a, int* b )
{
int t = *a;
*a = *b;
*b = t;
}

int partition (int arr[], int l, int h)


{
int x = arr[h];
int i = (l - 1),j;
for (j = l; j <= h- 1; j++)
{
if (arr[j] <= x)
{
i++;
swap (&arr[i], &arr[j]);
}
}
swap (&arr[i + 1], &arr[h]);
return (i + 1);
}

void quickSortIterative (int arr[], int l, int h)


{
int stack[10],p;
int top = -1;
stack[ ++top ] = l;
stack[ ++top ] = h;
while ( top >= 0 )
{
h = stack[ top-- ];
l = stack[ top-- ];
p = partition( arr, l, h );
if ( p-1 > l )
{
stack[ ++top ] = l;
stack[ ++top ] = p - 1;
}
if ( p+1 < h )
{
stack[ ++top ] = p + 1;
stack[ ++top ] = h;
}
}
}

int main()
{
int arr[20],n,i;
clrscr();

printf("Enter the size of the array");


scanf("%d",&n);

printf("Enter %d elements",n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);

quickSortIterative( arr, 0, n - 1 );

printf("Elements of the array are;");


for(i=0;i<n;i++)
printf("%d",arr[i]);

return 0;
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:…………………………….

10. Design, develop, code and run the program in any suitable language to implement an absolute
letter grading procedure, making suitable assumptions. Determine the basis paths and using them
derive different test cases, execute these test cases and discuss the test results.
PROGRAM CODE:
#include<stdio.h>
main()
{
float kan,eng,hindi,maths,science, sst,avmar;
printf("Letter Grading\n");
printf("SSLC Marks Grading\n");
printf("Enter the marks for Kannada:");
scanf("%f",&kan);
printf("enter the marks for English:");
scanf("%f",&eng);
printf("enter the marks for Hindi:");
scanf("%f",&hindi);
printf("enter the marks for Maths");
scanf("%f",&maths);
printf("enter the marks for Science:");
scanf("%f",&science);
printf("enter the marks for Social Science:");
scanf("%f",&sst);
avmar=(kan+eng+hindi+maths+science+sst)/6.25;
printf("the average marks are=%f\n",avmar);

if((avmar<35)&&(avmar>0))
printf("fail");

else if((avmar<=40)&&(avmar>35))
printf("Grade C");

else if((avmar<=50)&&(avmar>40))
printf("Grade C+");

else if((avmar<=60)&&(avmar>50))
printf("Grade B");

else if((avmar<=70)&&(avmar>60))
printf("Grade B+");

else if((avmar<=80)&&(avmar>70))
printf("Grade A");

else if((avmar<=100)&&(avmar>80))
printf("Grade A+");
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:……………………….

11. Design, develop, code and run the program in any suitable language to implement the NextDate
function.
Analyze it from the perspective of boundary value testing, derive different test cases, execute these
test cases and discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
main( )
{
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int d,m,y,nd,nm,ny,ndays;
clrscr( );
printf("enter the date,month,year");
scanf("%d%d%d",&d,&m,&y);

ndays=month[m-1];

if(y<=1812 && y>2012)


{
printf("Invalid Input Year");
exit(0);
}

if(d<=0 || d>ndays)
{
printf("Invalid Input Day");
exit(0);
}

if(m<1 && m>12)


{
printf("Invalid Input Month");
exit(0);
}

if(m==2)
{
if(y%100==0)
{
if(y%400==0)
ndays=29;
}
else if(y%4==0)
ndays=29;
}
nd=d+1;
nm=m;
ny=y;

if(nd>ndays)
{
nd=1;
nm++;
}

if(nm>12)

{
nm=1;
ny++;
}

printf("\n Given date is %d:%d:%d",d,m,y);


printf("\n Next day’s date is %d:%d:%d",nd,nm,ny);
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT
DATE:………………………….

12. Design, develop, code and run the program in any suitable language to implement the NextDate
function.
Analyze it from the perspective of equivalence class value testing, derive different test cases,
execute these test cases and discuss the test results.

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
main( )
{
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int d,m,y,nd,nm,ny,ndays;
clrscr( );
printf("enter the date,month,year");
scanf("%d%d%d",&d,&m,&y);
ndays=month[m-1];
if(y<=1812 && y>2012)
{
printf("Invalid Input Year");
exit(0);
}
if(d<=0 || d>ndays)
{
printf("Invalid Input Day");
exit(0);
}
if(m<1 && m>12)
{
printf("Invalid Input Month");
exit(0);
}
if(m==2)
{
if(y%100==0)
{
if(y%400==0)
ndays=29;
}
else if(y%4==0)
ndays=29;
}

nd=d+1;
nm=m;
ny=y;

if(nd>ndays)
{
nd=1;
nm++;
}
if(nm>12)
{
nm=1;
ny++;
}
printf("\n Given date is %d:%d:%d",d,m,y);
printf("\n Next day’s date is %d:%d:%d",nd,nm,ny);
getch( );
}
TEST REPORT:

SL.NO DESCRIPTION INPUTS EXPECTED ACTUAL COMMENTS


OUTPUT OUTPUT

You might also like