0% found this document useful (0 votes)
51 views7 pages

Reversing of A Number

The document describes a program to find the reverse of a number. It includes the code to take input from the user, check if it is a valid number, reverse the digits if valid using a while loop, and output the reversed number. Control flow and decision graphs are provided to visualize the program logic and conditions. Test cases are listed using boundary value analysis to test different boundaries and edges of the valid input range.

Uploaded by

Shubham Barolia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views7 pages

Reversing of A Number

The document describes a program to find the reverse of a number. It includes the code to take input from the user, check if it is a valid number, reverse the digits if valid using a while loop, and output the reversed number. Control flow and decision graphs are provided to visualize the program logic and conditions. Test cases are listed using boundary value analysis to test different boundaries and edges of the valid input range.

Uploaded by

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

PROGRAM TO FIND A REVRSE OF A NUMBER:

#include<stdio.h>

int main() 1

{ 2

int n, reverse = 0; 3

printf("Enter a number to reverse\n"); 4

scanf("%d",&n); 5

if(isalpha(n)==0) 6

{ 7

printf(“invalid input\n”); 8

} 9

else 10

{ 11

while (n != 0) 12

{ 13

reverse = reverse * 10; 14

reverse = reverse + n%10; 15

n = n/10; 16

} 17

printf("Reverse of entered number is = %d\n", reverse); 18

} 19

return 0; 20

)
To draw a DD-Graph we need to make Control Flow Graph first.

Control Flow Graph for Reverse of a number

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

Test cases for above decision table:


TEST CASES USING BOUNDARY VALUE ANALYSIS:

Boundary condition:
b1:10<=n<=999

Test case Id Test case input expected output actual output


description

Enter the values out


1 of the range 0 Out of range Out of range

2 Enter minimum-1 9 Out of range Out of range


Value

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

7 Enter maximum 999 Out of range Out of range


value

8 Enter maximum+1 1000 Out of range Out of range


value

9 Enter characters a Invalid input Invalid input

Enter negative
10 value -1 Out of range Out of range

You might also like