Professional Documents
Culture Documents
Reversing of A Number
Reversing of A Number
#include<stdio.h>
int main() 1
{ 2
int n, reverse = 0; 3
scanf("%d",&n); 5
if(isalpha(n)==0) 6
{ 7
printf(“invalid input\n”); 8
} 9
else 10
{ 11
while (n != 0) 12
{ 13
n = n/10; 16
} 17
} 19
return 0; 20
)
To draw a DD-Graph we need to make Control Flow Graph first.
7 1
0
8 1
1
9 1
2
1
3
1
4
1
5
16
17 18 1 20
9
2
1
Decision to Decision Graph for Reverse of a number
A A=1(INITIAL NODE)
B=(2,3,4,5)
B C=6
D=7, 8, 9
C
E=10, 11
F=12
D E
G=13, 14,15,16
F H=17
I=18, 19,20
G
END=21
EN
D
Decision Table for reverse of a Number
Conditions R1 R2 R3 R4
C1:num=alphabet? T F F F
C2:num<0? - T F F
C3:0<num<1000? - F T F
C4:num>=1000? - F F T
Actions
A1:not a valid X
number
A2:check for X
palindrome or
not
A3:out of range X X
TC Test case Input Expected Actual Status
ID description Output Output
1 Testing for a Invalid Invalid pass
requirement input Input
1
2 Testing for -1,0 Out of Out of pass
requirement range range
2
3 Testing for 1,10,867 Valid Valid pass
requirement input input
3
4 Testing for 1000,5001 Out of Out of Out of
requirement range range range
4
Boundary condition:
b1:10<=n<=999
3 Enter minimum 10 1 1
value
4 Enter minimum+1 11 11 11
value
5 Enter normal values 505 505 505
Enter maximum-1
6 value 998 889 889
Enter negative
10 value -1 Out of range Out of range