You are on page 1of 5

SQA - PRACTICAL NO -02

Q1. write a program to calculate sum of 5 numbers, numericals should


be in range of 20-50 and print the result (kindly take the inputs from the
user). draw EP and BVA and derive the test cases for the problem
statement.

step 1: write the program


#include <stdio.h>
#include <conio.h>
int main () {
int 5, i, sum = 0;
printf ("Enter a positive integer: ");
scanf ("%d", &5);

for (i = 1; i <= 5; ++i) {


sum += i;
}

Printf ("Sum = %d", sum);


return 0;
}

step 2: draw EP

ip: user to give the input

valid set invalid set


 Input: Int values alphabets, special character, float num
 =2digit <2digits
 =>20 between >=50 input value less than 20 and greater
than 50
 Must be a positive negative integer
integer

Step 3: draw BVA

checking for all 5 input values


 constraint 20-50
 lower limit :20
 upper limit :50
 mid value: any random value--35
 upper limit +1 :51
 lower limit -1:19

Step 4: Derive test case table

Sr no ip1 ip2 ip3 ip4 ip5 output result


1 20 30 20 20 20 110 pass
2 20 30 20 20 10 message prompts: fail
Invalid input.
Value must be btw the
range 20 to 50

3 1 20 20 20 20 message prompts: fail


Invalid input.
Value must be 2 digit-
integer and within the
range 20 to 50

4 1 1 1 1 20 message prompt: fail


Invalid input.
Value must be 2 digit-
integer and within the range 20
to 50

5 20 20 20 20 message prompts: fail


Please enter all the input
Value

6 20 g 20 20 20 message prompt: fail


Invalid input, input value is a character.
Only int value is accepted

7 20 # 20 20 20 message prompt: fail


Invalid input, input value is a special
character. Only int value is
accepted

8 21 31 41 50 36 179 pass
9 11 29 34 21 30.4 message prompt: fail
Invalid input, input value is a float.
Only int value is accepted
10 20 51 52 53 54 message prompts: fail
Invalid input, input value is a greater.
Value must be btw the
range 20 to 50
11 445 23 21 44 37 message prompts: fail
Invalid input, input value is a 3-digits.
Value must be btw the
range 20 to 50
12 -34 23 21 44 37 message prompts: fail
Invalid input, input is a negative integer.
Positive integer is accepted

Q2. write a program to print greatest of 2 numbers take the input


from the user inputs are integer values. draw EP and BVA and derive
the test cases for the problem statement

Solution:

step 1: write the program


#Program to find the greatest among two number using operators 
#Take two number from user to compare   
num1 = int (input ("Enter first number: ")) 
num2 = int (input ("Enter second number: "))  
#Compare both the number 
If (num1 - num2 > 0):
print ("{0} is largest than {1}".format(num1, num2))
elif(num2 - num1 > 0):    
print("{0} is largest than {1}".format(num2, num1))
else:     print("Both numbers are Equal")

#Take two number from user to compare                     


num1 = int(input("Enter first number: "))      
num2 = int(input("Enter second number: ")) 
#Compare both the number 
if num1 >= num2:   
    if num1 == num2:    
        print("Both numbers are equal.")       
    else:  
        print("Fisrt number is greater than the second number.")
else:   
    print("Second number is greater than the First number.") 

step 2: draw EP

ip: user to give the input


valid set invalid set
 Input: Int values alphabets, special character, float num
 Must be a positive negative integer
integer

Step 3: draw BVA

checking for the input values


 Constraint: Input must be integer values only.

Step 4: Derive test case table

Sr no ip1 ip2 output result


1 70 90 90 is greater than 70 pass
2 50 0.5 message prompt:
Invalid input, input value is a float.
Only int value is accepted fail

3 80 message prompts:
Please enter the input value fail

4 46 a message prompt:
Invalid input, input value is a character.
Only int value is accepted fail

5 35 & message prompts:


Invalid input, input value is a special
character. Only int value is
accepted fail

6 -1 60 message prompts:
Invalid input, input is a negative integer.
Positive integer is accepted fail

7 156 322 322 is greater than 156 pass

You might also like