ST Lab Program
ST Lab Program
ST Lab Program
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.
ALGORITHM:
Step 1: Input a, b & c i.e three integer values which represent three sides of
the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c < (a + b) then
do step 3
else
print not a triangle. do step 6.
Step 3: if (a=b) and (b=c) then
Print triangle formed is equilateral. do step 6.
Step 4: if (a ≠ b) and (a ≠ c) and (b ≠ c) then
Print triangle formed is scalene. do step 6.
Step 5: Print triangle formed is Isosceles.
Step 6: stop
PROGRAM CODE:
#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter three sides of the triangle");
scanf("%d%d%d", &a, &b, &c);
//range 1 to 10
if((a<=0 && a > 10) || (b<=0 && b > 10) || (c<=0 && c > 10))
{
printf("Out of range");
}
else
{
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;
}
Input Data
Expected Actual
Status Comments
Case Output Output
Description
Id
A b c
Should
Enter the display
min value the
1 1 1 1
for a , b message
and c Equilateral
triangle
Enter the Message
2 1 1 2 should be
min value
for 2 items displayed
and can't form
min +1 for a
any one triangle
item1
Enter the Message
min value should be
for 2 items displayed
3 and 1 2 1 can't form
min +1 for a
any one triangle
item1
Enter the Message
min value should be
for 2 items displayed
4 and 2 1 1 can't form
min +1 for a
any one triangle
item1
Enter the Should
normal display
value for 2 the
5 items 5 5 1 message
and 1 item Isosceles
is min triangle
value
Enter the Should
normal display
value for 2 the
6 items 5 1 5 message
and 1 item Isosceles
is min triangle
value
Enter the Should
normal display
value for 2 the
7 items 1 5 5 message
and 1 item Isosceles
is min triangle
value
Should
Enter the display
normal the
8 5 5 5 message
Value for a,
b and c Equilateral
triangle
Enter the
normal Should
value for 2 display
the
9 items 5 5 10
message
and 1 item Not a
is max triangle
value
10 Enter the Should
normal display
value for 2 the
items 5 10 5 message
and 1 item Not a
is max triangle
value
Enter the Should
normal display
value for 2 the
11 items 10 5 5 message
and 1 item Not a
is max triangle
value
Enter the Should
max value display
for 2 items the
12 and 10 10 9 message
max - 1 for Isosceles
any one triangle
item
2. 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
/* Assumption price for lock=45.0, stock=30.0 and barrels=25.0 production limit could sell in a
month 70 locks,80 stocks and 90 barrels. commission on sales = 10 % <= 1000 and 15 % on
1000 to 1800 and 20 % on above 1800*/ lock =-1 to end sales
tLocks =12
tStock= 15
tBarrels=19
Sales = 2000
3rd case
Sales= 577
#include<stdio.h>
int main()
lprice=45.0;
sprice=30.0;
bprice=25.0;
tlocks=0;
tstocks=0;
tbarrels=0;
printf("\nenter the number of locks and to exit the loop enter -1 for locks\n");
scanf("%d",&locks);
while(locks!=-1)
c1=(locks<=0||locks>70);
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
else
if(temp>70)
printf("new total locks =%d not in the range 1..70 so old ",temp);
else
tlocks=temp;
if(c2)
else
temp=tstocks+stocks;
if(temp>80)
printf("new total stocks =%d not in the range 1..80 so old ",temp);
else
tstocks=temp;
printf("total stocks=%d\n",tstocks);
if(c3)
else
temp=tbarrels+barrels;
if(temp>90)
printf("new total barrels =%d not in the range 1..90 so old ",temp);
else
tbarrels=temp;
printf("total barrel=%d",tbarrels);
printf("\nenter the number of locks and to exit the loop enter -1 for locks\n");
scanf("%d",&locks);
sales = lprice*tlocks+sprice*tstocks+bprice*tbarrels;
if(sales > 0)
comm=0.10*1000.0;
comm=comm+0.15*800;
comm=comm+0.20*(sales-1800.0);
}
comm =0.10*1000;
comm=comm+0.15*(sales-1000);
else
comm=0.10*sales;
else
printf("there is no sales\n");
return 0;
Enter the
values to
calculate
the
commissi 100
10 10 10 100
on for 0
sales
nearly
less than
1000
10 Enter the
values
sales 102
10 10 11 103.75
exactly 5
equal to
1000
103
10 11 10 104.5
0
104
11 10 10 106.75
5
14 14 14