Tutorial-11: To calculate the value of (a to the power b) and Generate its Decision Table based Test Cases
Inputs for the Tutorial: An expression ( ab ) with input as two integers a & b.
Objective of this Tutorial: There are two objectives of the tutorial like:
Objective 1: To write a Program in C++ for the determining the value of expression ( ab ).
Objective 2: Decision Table Based testing for situations in which a number of combinations of actions shall be taken for different conditions. Four parts of decision table being covered shall be: Condition Stub, Action Stub, Condition Entries and Action Entries.
Solution Part 1: Program in C++
#include
#include
#include
void main()
c1rscr();
int a,b;
float c;
char ch;
I : cout<<TO P < b?n?; power the to `a CALCULATE>
cin>>;
c=pow(a,b);
cout<<endl<<; <=”” p=””></endl<<;>
cout<<“nWant to enter again?(y/n)
cin>>ch;
if((ch==’y’)||(ch==’Y’))
goto I;
getch();
}
Solution Part 2: Decision Table Based Test Cases
Test Case ID | a | b | Expected Output |
1 | 2 | 3 | +ve Result |
2 | -1 | 3 | -ve Result |
3 | -2 | -4 | +ve Result |
4 | 0 | 1 | Result is 0 |
5 | 0 | 0 | Domain Error |
6 | -1 | -0.6 | Result is 1 |
Decision Table is as under
Conditions | ||||||||
C1:a = 0,b = 0 | T | |||||||
C2:a = -ve, b = +ve | T | |||||||
C3:a = +ve, b = -ve | T | |||||||
C4:a = -ve, b = -ve | T | |||||||
C5:a = +ve, b = +ve | T | |||||||
C6:a = 0, b = integer | T | |||||||
C7:b = 0, a = integer | T | |||||||
C8:a = -ve, b = -ve odd | T | |||||||
Actions | ||||||||
A1: Domain Error | X | |||||||
A2: Negative Output | X | |||||||
A3: Output = 1 | X | |||||||
A4: Positive Output | X | X | X | |||||
A5: Output = 0 | X |
Screenshot with different outputs is as under:
Many More Articles & Tutorials on Black Box Testing

An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.