Software testing
1.SUM OF INDIVIDUAL DIGITS
AIM:
To write a c program find the sum of individual digits.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a C program to find the sum of individual digits of a 10-digit number until a single digit is produced.
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE: -
#include<stdio.h> #include<conio.h> void main()
{
char num[9]; int i,val=0,sum=0,r=0; clrscr(); loop1: printf(“\tEnter 10 digit number:”); scanf(“%s”,&num);
for(i=0;i<10;i++)
{
if(isdigit(num[i])==0)
{
printf(“\nInput Invalid!!!”);
fflush(stdin); sum=0; goto loop1;
}
sum=sum+(num[i]-‘0’);
}
do
{
sum=0; while(val!=0)
{
r=val%10; sum=sum+r; val=val/10;
}
printf(“\n%d”,sum); val=sum; }while(sum>9); getch();
}
TEST CASES :-
TEST – ID TEST
DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC – 01 Prompts for input. Run the program Prompts for a 10 digit number. Prompts for a 10 digit number. Success
TC – 02 Acceptance of 10 digit number input. Type 10 digits and hit enter key. Accepts the in put. Accepts the input. Success
TC – 03 Non – acceptance of digits less than 10. Type 8 digits and hit enter key. Displays message prompts again. error and input Displays error message and prompts input again. Success
TC – 04 Non – acceptance of digits more than 10. Type more than 10 digits. Accepts only first 10 digits. Accepts only first 10 digits. Success
TC – 05 Non acceptance alphabetic characters. – of Input a character data 'X'. Character X should not be accepted. Character X is not accepted. Success
TC – 06 Non acceptance special characters. – of Input special characters. Special characters should not be accepted. Special character is not accepted. Success
TC – 07 Non acceptance decimal number. – of Input a decimal number. Decimal point should not be accepted. Decimal point is not accepted. Success
TC – 08 Generates stepwise sum. Input data and hit enter. Generates step-wise sum of individual digits from previous step. Generates step-
wise sum of individual digits from previous step. Success
TC – 09 Generates single digit output. Input data and hit enter. Generates single digit sum of individual digits from previous step in the final step. Generates single digit sum of individual digits from previous step in the final step. Success
TC – 10 Program terminates normally. Input data and hit enter. Program terminates after producing the output. Program terminates after producing the output. Success
OUTPUT:-
Enter 10 digit number : 89ffv5873
Input Invalid!!!
Enter 10 digit number : 895873
Input Invalid!!!
Enter 10 digit number : 3659821548
51
6
2.STUDENT RESULTS
AIM:
To write a c program to find the result of students.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a C program to accept the inputs student Name, Marks for five subjects and declare the result as PASS if the student gets minimum 40 in each subject otherwise declare the result as FAIL.
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE:-
#include<stdio.h> #include<conio.h>
void main()
{
char name[30]; int i,m1,m2,m3,m4,m5;
clrscr(); N1:
fflush(stdin); printf(“\nEnter student name:”); scanf(“%[^\n]s”,&name);
for(i=0;i<strlen(name);i++)
{
if((isalpha(name[i])==0)&& (isspace(name[i])==0))
{
printf(“Invalid Name!!!”); goto N1;
}
}
printf(“\nEnter marks:”); M1:
printf(“\nTamil:”); scanf(“%d”,&m1);
if(m1>100)
{
printf(“Invalid mark”);
goto M1;
}
M2:
printf(“\nEnglish:”); scanf(“%d”,&m2);
if(m2>100)
{
printf(“Invalid mark”); goto M2;
}
M3:
printf(“\nMaths:”); scanf(“%d”,&m3);
if(m3>100)
{
printf(“Invalid mark”);
goto M3;
}
M4:
printf(“\nScience:”); scanf(“%d”,&m4);
if(m4>100)
{
printf(“Invalid mark”);
goto M4;
}
M5:
printf(“\nSocial:”);
scanf(“%d”,&m5);
if(m5>100)
{
printf(“Invalid mark”); goto M5;
}
clrscr();
printf(“\n\nName :%s”,name); printf(“\nTamil :%d”,m1); printf(“\nEnglish:%d”,m2); printf(“\nMaths :%d”,m3); printf(“\nScience:%d”,m4); printf(“\nSocial :%d”,m5);
printf(“\nResult :”);
if(m1<40|| m2<40|| m3<40|| m4<40|| m5<40)
printf(“Fail”);
printf(“Pass”);
else
getch();
}
TEST CASES :-
TEST – ID TEST
DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC - 01 Prompts for input. Run the program Prompts for student name. Prompts for student name. Success
TC – 02 Acceptance of alphabetic characters and blank space. Type alphabetic characters with space. Accepts the input. Accepts the input. Success
TC – 03 Non – acceptance of alpha-numeric characters. Type in numbers and special characters. Prompts for input again. Prompts for input again. Success
TC – 04 Prompts for marks. Run the program. Input the student name and five marks. Prompts for marks five times. Prompts for marks five times. Success
TC – 05 Acceptance of marks in five subjects that are less than or equal to 100. Type numbers less than or equal to 100 for each prompt. Accepts the input. Accepts the input. Success
TC – 06 Non - acceptance of marks greater than 100. Type numbers greater than 100. Prompts for input again. Prompts for input again. Success
TC – 07 Non – acceptance of alpha-numeric characters for marks. Input a character data
'X'. Character X should not be accepted. Character X is not accepted. Success
TC – 08 Display result as PASS. Input five marks greater than or equal to 40 and less than or equal to 100. Displays the result as PASS. Displays the result as PASS. Success
TC – 09 Display result as FAIL. Input one mark less than 40. Displays the result as FAIL. Displays the result as FAIL. Success
TC – 10 Program terminates normally. Input data and hit enter. Program terminates after producing the output. Program terminates after producing the output. Success
OUTPUT:-
Enter student name: Leema Enter marks: Tamil:90
English:87
Maths:800
Invalid mark
Maths:80
Science:67
Social:78
Name: Leema
Tamil:90
English:87 Maths:80
Science:67
Social:78
Result:Pass
Enter student name: Monica
Enter marks: Tamil:78
English:45 Maths:0
Science:67
Social:56
Name: Monica
Tamil:78
English:45 Maths:0
Science:67
Social:56 Result:Fail
3.PRIME NUMBER
AIM:
To write a c program to find the result of the students.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a C program to generate 'n' prime numbers.
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE: -
#include<stdio.h> #include<conio.h>
void main()
{ int n,i,j,k; char ch; L2: clrscr(); L3: fflush(stdin); n=-1;
printf(“How many prime numbers to generate?”); scanf(“%d”, &n);
if(n<0)
{
printf(“Invalid number!!!\n”); goto L3;
}
for(i=1;i<=3&&i<n;i++) printf(“%d\t”,i); j=5;
while(i<=n)
{
k=3;
while(k!=j)
{
if(j%k==0) goto L1; k=k+2;
}
printf(“%d\t”,j); i++;
L1: j=j+2;
} if(i!=1)
{
printf(“\n\nDo you wish to continue?(Y/N)”); ch=getche(); if(ch==’y’||ch==’Y’)
goto L2;
}
else goto L2; getch();
}
TEST CASES: -
TEST – ID TEST
DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC - 01 Prompts for input. Run the program Prompts for number of prime values to generate. Prompts for number of prime values to generate. Success
TC – 02 Acceptance of numeric input. Type 6. Accepts the input. Accepts the input. Success
TC – 03 Non – acceptance of non-numeric data. Input a character data 'X'. Displays error message and prompts for input. Displays error message and prompts for input. Success
TC – 04 Generates prime numbers not less or not more than user request. Type the value 10. Displays 10 prime numbers. Displays 10 prime numbers. Success
TC – 05 Generates exact number of prime numbers. Type the value 15. Displays exactly 15 prime numbers. Displays exactly 15 prime numbers. Success
TC – 06 Even number is not displayed except 2. Type the value 8. Does not display the numbers
4,6,8,10,12,14 and
16. Does not display the numbers 4,6,8,10,12,14 and 16. Success
TC – 07 Non-prime numbers are not displayed. Type the value 7. Does not display the non-prime numbers
4,6,8,9,10 and 12 . Does not display the nonprime numbers 4,6,8,9,10 and 12 . Success
TC – 08 Prompt for user choice to continue. Type a value and hit enter. Displays the result and prompts for user choice to continue. Displays the result and prompts for user choice to continue. Success
TC – 09 Program should be re-executed if continue is chosen. Type the option as "y" Program is reexecuted. Program is re-executed. Success
TC – 10 Program should be terminated when chosen to exit. Type the option as "n" Program is terminated. Program is terminated. Success
OUTPUT: -
How many prime numbers to generate?12
1 2 3 5 7 11 13 17 19 23 29 31
Do you wish to continue? (Y/N) y
How many prime numbers to generate?6
1 2 3 5 7 11
Do you wish to continue? (Y/N) n
4.MERGE AND SORT
AIM:
To write a c program to sort and store the elements of tow arrays into the third array.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a C program to sort and store the elements of two integer arrays into the third list.
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE: -
#include <stdio.h>
void merge(int[], int, int[], int, int[]); void sort(int[], int);
int clean_stdin()
{
while(getchar()!='\n'); return 1;
}
void main()
{
int l1[20], l2[20], m, n, c, l3[40]; char ch; clrscr(); do
{
printf("Input number of elements in List1(Max 20):");
}
while(((scanf("%d%c", &m,&ch)!=2||ch!='\n')&&clean_stdin())||m<1||m>20); printf("Input integers for List1:\n", m); for (c = 0; c < m; c++)
{
do
{
printf("Integer %d:",c+1);
}
while((scanf("%d%c",&l1[c],&ch)!=2||ch!='\n')&&clean_stdin());
}
do
{
printf("Input number of elements in List2(Max 20):");
}
while(((scanf("%d%c", &n,&ch)!=2||ch!='\n')&&clean_stdin())||n<1||n>20);
printf("Input integers for List2:\n", n); for (c = 0; c < n; c++)
{
do
{
printf("Integer %d:",c+1);
}
while((scanf("%d%c",&l2[c],&ch)!=2||ch!='\n')&&clean_stdin());
}
merge(l1, m, l2, n, l3); sort(l3, m+n);
printf("Sorted List:\n");
for (c = 0; c < m + n; c++) printf("%d\t", l3[c]); getch();
}
void merge(int l1[], int m, int l2[], int n, int l3[])
{
int i,j;
for(i=0;i<m;i++) l3[i]=l1[i]; for(j=0;j<n;j++,i++) l3[i]=l2[j];
}
void sort(int l3[], int no)
{ int i, j,k;
for(i=0;i<no;i++) for(j=i+1;j<no;j++) if (l3[i]>l3[j])
{ k=l3[i]; l3[i]=l3[j]; l3[j]=k;
}
}
TEST CASES : -
TEST –
ID TEST DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC - 01 Prompts for input. Run the program Prompts for number of elements N for the
2 lists. Prompts for number of elements N for the 2 lists. Success
TC – 05 Acceptance of list length within maximum limit. Input list length greater than maximum size. Prompts for input again. Prompts for input again. Success
TC – 02 Acceptance of exactly N number of integers into each list. Run the program. Type the number of elements for the lists and hit enter. Prompts for N number of integers for each list. Prompts for N number of integers for each list. Success
TC – 03 Non–acceptance of non–numeric data. Input non-numeric data. Displays error message and prompts input again. Displays error message and prompts input again. Success
TC – 04 Acceptance of signed integers. Input negative values. Accepts the input. Accepts the input. Success
TC – 06 Non – acceptance of decimal values. Input decimal value. Displays error message and prompts input again. Displays error message and prompts input again. Success
TC – 07 Should produce the merged list of the given two list elements. Enter the elements into both the lists. The two list elements are merged single list. into a The two list elements are merged into a single list. Success
TC – 08 Sort the elements in the combined list. Enter the elements into both the lists. Elements combined sorted. in list the are Elements in the combined list are sorted. Success
TC – 09 Allowance of duplicate elements in the combined list. Enter duplicate elements in the arrays. Elements duplicated in combined list. are the Elements are duplicated in the combined list. Success
TC – 10 Program terminates normally. Input data and hit enter. Program waits for user to enter a key to terminate after producing the output. Program waits for user to enter a key to terminate after producing the output. Success
OUTPUT FOR MERGE AND SORT:
Input number of elements in List1(Max 20):4 Input integers for List1:
Integer 1:59
Integer 2:84
Integer 3:56
Integer 4:78
Input number of elements in List1(Max 20):5 Input integers for List1:
Integer 1:65
Integer 2:45
Integer 3:20
Integer 4:35
Integer 5:44 Sorted List:
20 35 44 45 56 59 65 78
84
5.STACK OPERATION
AIM:
To write a c program to experiment the operations of stack using arrays.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a C program to experiment the operations of STACK using arrays.
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE: -
#include<stdio.h> struct stack { char s[5];
int top;
} st;
int clean_stdin()
{
while(getchar()!='\n'); return 1;
}
int stfull() { if (st.top >= 4) return 1; else return 0;
}
void push(char item) { st.top++; st.s[st.top] = item;
}
int stempty() { if (st.top == -1) return 1; else return 0;
}
char pop() { char item; item = st.s[st.top]; st.top--;
return (item);
}
void display() { int i;
if (stempty()) printf("\nStack Is Empty!"); else { for (i = st.top; i >= 0; i--)
printf("\n%c", st.s[i]);
}
}
int main()
{
int choice; char item,ans,ch;
st.top = -1;
do{
clrscr();
printf("\n\tImplementation Of Stack"); printf("\nMain Menu");
printf("\n1.Push \n2.Pop \n3.Display \n4.exit"); do
{
printf("\nEnter Your Choice:");
}
while(((scanf("%d%c", &choice, &ch)!=2||ch!='\n')&& clean_stdin())||choice<1||choice>4); switch (choice) { case 1:
if (stfull())
printf("\nStack is Full! Overflow!!"); else
printf("\nEnter the item to be pushed:"); scanf("%c", &item); fflush(stdin); push(item); break; case 2:
if (stempty())
printf("\nEmpty stack! Underflow!!"); else { item = pop();
printf("\nThe popped element is %c", item);
}
break; case 3: display(); break; case 4: exit(0);
}
printf("\nDo You want To Continue?");
ans = getche();
} while (ans == 'Y' || ans == 'y');
return 0;
}
TEST CASES: -
TEST – ID TEST DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC – 01 Display a menu allowing the user to select one. Run the Program. Menu is displayed. Menu is displayed. Success
TC – 02 Prompts for input. Run the Program. Prompts for user choice. Prompts for user choice. Success
TC – 03 User choice must be an integer value. Enter a non integer choice value. Prompts input again. Prompts input again. Success
TC – 04 Branches to the correct function when user selects the choice. Enter ‘1’ corresponding to insert menu. Prompts for an input to enqueue. Prompts for an input to enqueue. Success
TC – 05 While inserting if the stack is full report the status. Select the push option when the stack is full. Stack Overflow message is displayed. Stack Overflow message is displayed. Success
TC – 06 Insert the element at top of the stack. Select the push option and enter the element. Element added to the top of the stack. Element added to the top of the stack. Success
TC – 07 While deleting if the stack is empty report the status. Select the pop option when the stack is empty. Stack Underflow message is displayed. Stack Underflow message is displayed. Success
TC – 08 Delete the element at top of the stack. Select the pop option. Element deleted at the top of the stack. Element deleted at the top of the stack. Success
TC – 09 Display the stack elements in LIFO order when display is selected. Select display option. Elements are displayed in LIFO order. Elements are displayed in LIFO order. Success
TC – 10 Terminates when the user selects Exit. Select Exit option. Program is terminated. Program is terminated. Success
OUTPUT: -
Implementation Of Stack
Main Menu
1.Push
2.Pop
3.Display
4.exit
Enter Your Choice:1
Enter the item to be pushed:5
Do You want To Continue?Y
Implementation Of Stack
Main Menu
1.Push
2.Pop
3.Display
4.exit
Enter Your Choice:2
The popped element is 5
Do You want To Continue?Y
Implementation Of Stack
Main Menu
1.Push
2.Pop
3.Display 4.exit Enter Your Choice:3 Stack Is Empty!
Do You want To Continue?Y
Implementation Of Stack
Main Menu
1.Push
2.Pop
3.Display 4.exit
Enter Your Choice:4
6.QUEUE OPERATION
AIM:
To write a menu-driven c program to perform the queue operation.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a menu-driven C program to perform the following QUEUE operations:
1. Insertion
2. Deletion
3. Modification
4. List
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE: -
#include <stdio.h> int queue[10], front=0, rear=-1; char ch;
void insert_rear()
{ int val; if (rear>=9)
{
printf("QUEUE FULL");
}
else
{
printf("\nEnter the value you want to insert in the queue:"); scanf("%d", &val); rear++; queue[rear] = val;
printf("\nElement successfully inserted in the queue");
}
}
void delete_front()
{
if (rear==-1)
{
printf("QUEUE EMPTY");
}
else
{
printf("\nThe deleted element is: %d", queue[front]); front++;
}
}
void display_queue()
{ int i;
if (rear==-1)
{
printf("QUEUE EMPTY");
}
else
{
for (i = front;i <= rear;i++)
{
printf("%d\t", queue[i]);
}
}
}
void modify_queue()
{
printf("\n This destroys the existing queue and creates a new queue."); printf("\n Do you wish to continue(y/n)?"); scanf("%c",&ch); if(ch=='y'||ch=='Y')
{
front=0; rear=-1;
printf("\n A new queue has been created.");
}
else
{
printf("\n Modification Aborted!");
}
}
int clean_stdin()
{
while(getchar()!='\n'); return 1;
}
void main()
{
int choice, n; do
{ clrscr();
printf("\t\tIMPLEMENTATION OF QUEUE");
printf("\nMain Menu");
printf("\n1 INSERT \n2 DELETE\n3 MODIFICATION\n4 LIST\n5 EXIT\n"); do
{
printf("Enter your Choice:");
}
while(((scanf("%d%c", &choice, &ch)!=2||ch!='\n')&& clean_stdin())||choice<1||choice>5); switch(choice)
{
case 1: insert_rear(); break; case 2: delete_front(); break; case 3:
modify_queue(); break; case 4: display_queue(); break; case 5: exit(0);
}
printf("\nDo you want to continue:"); scanf(" %c", &ch);
} while(ch == 'y' || ch == 'Y');
}
TEST CASES : -
TEST – ID TEST
DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC – 01 Display of menu items. Run the Program. Menu of queue operations displayed. Menu of queue operations displayed. Success
TC - 02 Prompt the user to select the choice from the menu. Run the Program. Menu is displayed and prompts to select a choice. Menu is displayed and prompts to select a choice. Success
TC – 03 User choice must be an integer value. Enter a non integer choice value. Prompts input again. Prompts input again. Success
TC – 04 Branches to the correct function when user selects the choice. Enter ‘1’ corresponding to INSERT menu. Prompts for an input to enqueue. Prompts for an input to enqueue. Success
TC – 05 An element should be added to the end of the queue. Select INSERT and enter an element. Given element is added to the end of the queue. Given element is added to the end of the queue. Success
TC – 06 Delete an element at the front of the queue. Select DELETE option. Element at the front is deleted. Element at the front is deleted. Success
TC – 07 Provides queue destruction alert. Select
MODIFICATION option. Queue destruction alert is displayed. Queue destruction alert is displayed. Success
TC – 08 Creates new queue when modified. Select
MODIFICATION and press ‘y’. Destroys available queue and creates a new queue. Destroys available queue and creates a new queue. Success
TC – 09 Elements Should be displayed in FIFO order. Select LIST option. Elements are displayed in FIFO fashion. Elements are displayed in FIFO fashion. Success
TC – 10 Terminates when exit is selected. Select the Exit option. Program is terminated. Program is terminated. Success
OUTPUT: -
IMPLEMENTATION OF QUEUE
Main Menu
1 INSERT
2 DELETE
3 MODIFICATION
4 LIST
5 EXIT
Enter your Choice:1
Enter the value you want to insert in the queue:12
Element successfully inserted in the queue
Do you want to continue:Y
IMPLEMENTATION OF QUEUE
Main Menu
1 INSERT
2 DELETE
3 MODIFICATION
4 LIST
5 EXIT
Enter your Choice:2
The deleted element is: 12
Do you want to continue:Y
IMPLEMENTATION OF QUEUE
Main Menu
1 INSERT
2 DELETE
3 MODIFICATION
4 LIST
5 EXIT
Enter your Choice:3
This destroys the existing queue and creates a new queue. Do you wish to continue(y/n)?Y A new queue has been created.
Do you want to continue:Y
IMPLEMENTATION OF QUEUE
Main Menu
1 INSERT
2 DELETE
3 MODIFICATION
4 LIST
5 EXIT
Enter your Choice:4
QUEUE EMPTY
Do you want to continue:Y
IMPLEMENTATION OF QUEUE
Main Menu
1 INSERT
2 DELETE
3 MODIFICATION
4 LIST
5 EXIT
Enter your Choice:5
7.PALINDROME
AIM:
To write a c++ program using pointers to check if a string is palindrome.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Create a C++ program using Pointers to check if a string is Palindrome.
STEP 3: Compile and run the program.
STEP 4: Write test cases for input data, conditional expressions, control transfer, output, etc.
STEP 5: Run the program and follow the steps described in the test case.
STEP 6: Debug and run the program until all the test cases succeeds.
STEP 7: Do steps 5 and 6 for all the test cases.
STEP 8: Stop the process.
PROGRAM CODE: -
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
char *str,str1[20],*str2,ch;
int flag=0,i=0,j; do
{
clrscr(); cout<<"\nEnter the string:"; cin.getline(str1,20); str=str1; j=strlen(str1)-1;
while(i<=j)
{ if(str[i]!=str[j]) flag=1;
i++;
j--;
}
cout<<"\nThe reverse of "<<str1; cout<<" is "<<strrev(str1); if(flag==0)
cout<<"\n\nThus the string is a palindrome!!!"; else cout<<"\n\nThus the string is not a palindrome!!!"; cout<<"\n\nDo you wish to continue(Y/N):"; ch=getch(); }while(ch=='y'||ch=='Y');
}
TEST CASES:
TEST – ID TEST
DESCRIPTION TEST STEPS EXPECTED VALUE ACTUAL VALUE STATUS
TC - 01 Prompts for input. Run the program. Prompts to enter a string. Prompts to enter a string. Success
TC – 02 Acceptance of the input. Enter a string. Accepts the given string. Accepts the given string. Success
TC – 03 Acceptance of any series of character. Enter the string with different characters. Accepts the given string. Accepts the given string. Success
TC – 04 Display the string in reverse order. Enter the string. Displays the given string in reverse order. Displays the given string in reverse order. Success
TC – 05 Checks weather the string is a palindrome or not. Enter the string. Displays the given string in reverse order and the result. Displays the given string in reverse order and the result. Success
TC – 06 If the entered string and its reverse are equal flag it as palindrome. Enter a string which is a palindrome as “madam”. Display the string is a palindrome. Display the string is a palindrome. Success
TC – 07 If the entered string and its reverse are not equal flag it as not a palindrome. Enter a string which is not a palindrome as “clever”. Display the string is not a palindrome. Display the string is not a palindrome. Success
TC – 08 Prompt for user choice to continue. Enter the string. Displays the result and prompts for user choice to continue. Displays the result and prompts for user choice to continue. Success
TC – 09 Program should be re-executed if continue is chosen. Select the option as "y" Program is reexecuted. Program is re-executed. Success
TC – 10 Program should be terminated when chosen to exit. Select the option as "n" Program is terminated. Program is terminated. Success
OUTPUT: -
Enter the string:HAPPY
The reverse of HAPPY is YPPAH
Thus the string is not a palindrome!!!
Do you wish to continue(Y/N):Y
Enter the string:MADAM
The reverse of MADAM is MADAM
Thus the string is a palindrome!!!
Do you wish to continue(Y/N):N


Comments
Post a Comment