Skill-4 - CS: Software Testinglab List of Programs
Skill-4 - CS: Software Testinglab List of Programs
Skill-4 - CS: Software Testinglab List of Programs
LIST OF PROGRAMS
1. Test the C program: Finding the sum of individual digits of a 10-digit number until a single
digit is produced.
2. Test the C Program: Accept the inputs student name, marks in five subjects and declare the
result as PASS if the student gets minimum 40 in each subject; otherwise declare the result as
FAIL.
4. Test the C program: Sort and store the elements of two arrays of integers into the third list.
5. Test the C program: Experiment the operations of a stack using array implementation.
6. Test the C program: Menu-driven option for queue operations like add, remove and display.
7. Test the C++ program: Palindrome string checking program (using pointers)
Ex.No.01
AIM:
To test a C program for finding the sum of individual digit of a 10 digit number until a
single digit is produced.
ALGORITHM:
Step 2: Open TC present in the program files to open the C programming environment.
Step 4: Get 10 digits from the user which is stored in the variable called temp for temporary
storage.
Step 5: Performing the operations of sum of individual digits given by the user.
Step 6: Sum of individual digit is displayed finally using display function.
SOURCE CODE:
TEST CASES:
OUTPUT:-
Ex.No.02
STUDENT MARKSHEET RESULT
AIM:
To test a C program to accept the inputs student name, marks in five subjects and declare the
results as pass if the student gets minimum 40 in each subject, otherwise declare the result as
FAIL.
ALGORITHM:
Step 3: Declare the main function under it declare the required variables such as
rollno,name,m1,m2,m3,m4,m5.
Step 4: Get the name and roll number and five subject marks from the user using get statement.
Step 5: The marks are checked using if statement and finally the result is displayed “pass” or
“Fail”.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int rollno, m1,m2,m3,m4,m5;
char name[30];
printf(“enter roll no:”);
scanf(“%d”, &rollno);
printf(“enter name:”);
scanf(“%s”, &name);
printf((“enter marks for 5 subjects:”);
scanf(“%d%d%d%d%d”,&m1,&m2,&m3,&m4,&m5);
if ( (m1<40)||(m2<40)||(m3<40)||(m4<40)||(m5<40))
{
printf(“RESULT IS FAIL”);
}
else
{
printf(“RESULT IS PASS”);
}
getch();
}
TEST CASES:
OUTPUT :-
STUDENT MARKLIST
Ex.No.03
AIM:
ALGORITHM:
Step 3: Take the integer variable i, divide the variable i with (i-1 to 2)
Step 4: If variable i is divisible by any value (i-1 to 2 ) it is not prime, otherwise it is prime.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,y;
clrscr();
printf("\n\t\t\t Generating prime numbers");
printf("\n\n\tEnter the value for n:");
scanf("%d",&n);
printf("\n\n\t**Prime numbers between 1 to \%d**\n",n);
printf("\n\t1 is neither or not prime number\n");
for(i=2;i<=n;i++)
{
y=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
y=1;
break;
}
}
if(y==0)
{
printf("\n\tprime number:%d",i);
}
}
getch();
}
TEST CASES:
TEST
TEST EXPECTED ACTUAL
- TEST STEPS STATUS
DESCRIPTION OUTPUT OUTPUT
ID
TC-01 Input case- Enter the n number as Accept Input when Accepted Input is SUCCESS
Positive. integer for generating n is an integer of the type int
prime numbers.
TC-02 Input case- Enter the n number as “Kindly Input a “Kindly Input a SUCCESS
Negative. character for generating valid Data”. valid Data”.
prime numbers.
TC-03 Process case- Check Type the number in Accept the values Accepted the SUCCESS
whether it producing a integer until it generates in integers. values in integers.
list of prime numbers– the sequence
Positive.
TC-04 Process case- Check Type the number in Don’t accept the Not accepting the SUCCESS
whether it is integer until it produces value if it produce values.
prompting to enter a a prime number format. a final output as
number starts from 1- another format.
Negative.
TC-05 Output case- Check 1. Title of the program. PRIME PRIME SUCCESS
for the formatted 2. Input query. FORMAT enters FORMAT enters
output. 3. Output query. the respective no. the respective no.
Display prime no. Display prime no.
TC-06 INPUT-CASE Enter the date as Accept the date. Accepted the date. SUCCESS
DDMMYY format.
TC-07 DATE-CASE. Convert the date as Accept the Accepted the SUCCESS
character. characters. characters.
TC-09 DISP-CASE. Display the generated The prime numbers The prime number SUCCESS
number. list will be list is displayed.
displayed.
OUTPUT :-
Enter the value of n
7
2357
Ex.No: 4
AIM:
To test a C program to sort and store the elements of two arrays of type integers into the
third list.
ALGORITHM:
Step 3: Initialize the size for the input array variables to zero using a loop.
Step 4: Enter the size of an array and the elements in array 1 and array2 during runtime.
Step 5: Compare the elements of array1 and array 2 using decision making statement and sort the
elements.
Step 6:The sorted list of array1 and array2 are merged and stored as values in array3.
TEST CASES:
TEST
TEST EXPECTED ACTUAL
- TEST STEPS STATUS
DESCRIPTION OUTPUT OUTPUT
ID
Input case- Enter the Input should be an
TC-01 Valid Valid SUCCESS
size of 2 arrays. integer value.
Input case- Enter the If input is float or
TC-02 Invalid Invalid SUCCESS
size of 2 arrays. character.
Input case -Enter the Input should be an
TC-03 Valid Valid SUCCESS
elements of arrays. integer value.
Input case -Enter the If input is float or
TC-04 Invalid Invalid SUCCESS
elements of arrays. character.
Process case -First
and second array It should be in sorted
TC-05 Valid Valid SUCCESS
elements (while order.
merging).
Process case -First
and second array It should be in unsorted
TC-06 Invalid Invalid SUCCESS
elements (while order.
merging).
Array elements are
Process case -First
compared and largest
TC-07 and second array Valid Valid SUCCESS
element is added to the
elements are merged.
third array.
Array elements are
Process case -First
compared and largest
TC-08 and second array Invalid Invalid SUCCESS
element is added to the
elements are merged.
third array.
Output case –Check
Produce Third array in
TC-09 for the formatted Valid Valid SUCCESS
sorted order.
output.
Output case –Check
Produce Third array in
TC-10 for the formatted Valid Valid SUCCESS
unsorted order.
output.
OUTPUT :-
Enter the limit of first array:3
Enter the elements of first array
4
5
6
Enter the limit of second array:3
Enter the elements of second array
1
2
3
Sorted First array:
4 5 6
Sorted second array
1 2 3
Ex.No: 5
STACK OPERATIONS
AIM:
ALGORITHM:
Step 2: Declare the variables as stack, top, i and choice for stack operation.
Step 3: Get the input for the size of the stack and the elements in the stack.
Step 4: Check using theif condition to validate when the maximum size of stack occursin
overflow.
Step 5: Use top=top+1 to increment the top 1, to push the elements at the top of stack, and then
SOURCE CODE:
#include<stdio.h> //preprocessor directives
#include<conio.h>
void main()
{
int stack[10],t,top=0,i,choice,item,size; //variable declaration
clrscr(); //clearing the screen
printf("Enter the size of stack:");
scanf("%d",&size); //To read size of stack
do
{
printf("\n\t\t\t Stack Operations"); // Displays menu(options)
printf("\n1.Push");
printf("\n2.Pop");
printf("\n3.Show");
printf("\n4.Exit");
printf("\n Enter your choice:");
scanf("%d",&choice); // To read the option from menu
switch(choice)
{
case 1: // To perform push operation
if(top>=size) /*Top reaches maximum size of stack
then stack overflow*/
{
printf("\n Stack Overflow");
break;
}
else
printf("Enter the item to push:");
scanf("%d",&item); // read new item to push
stack[top]=item; // push element at top of stack
top=top+1; // Incrementing top
break;
case 2: //To perform pop operation
if(top==0) // if Top equal to zero then stack is empty
{
printf("\n Stack Underflow");
break;
}
else
top--; //Decrementing top
t=stack[top]; //moving top element to temporary variable
TEST CASES:
TEST
TEST EXPECTED ACTUAL
- TEST STEPS STATUS
DESCRIPTION OUTPUT OUTPUT
ID
TC-01 Input case- Enter the It should be an integer Valid Valid SUCCESS
size of stack. value.
TC-02 Input case- Enter the If input is float or Invalid Invalid SUCCESS
size of stack. character.
TC-03 Input case -Enter the It should be an integer Valid Valid SUCCESS
choice to perform the value.
specified action.
TC-04 Input case -Enter the If input is float or Invalid Invalid SUCCESS
choice to perform the character.
specified action.
TC-05 Process case – Initialize the top=0 then Valid Valid SUCCESS
INSERTION: Enter it is incremented.
the choice as push.
TC-06 Process case – Initialize the top!=0 Invalid Invalid SUCCESS
INSERTION: Enter then it is decremented.
the choice as push.
TC-07 Process case – The top decremented by Valid Valid SUCCESS
DELETION: Enter one and it displays the
the choice as pop. popped element.
TC-08 Process case – The top incremented by Invalid Invalid SUCCESS
DELETION: Enter one and it displays the
the choice as pop. popped element.
TC-09 Output case –Check If valid choice is given Valid Valid SUCCESS
for the formatted perform the specific
output. task.
TC-10 Output case –Check If valid choice is given Invalid Invalid SUCCESS
for the formatted perform the specific
output. task.
OUTPUT :-
Enter the size of stack:3
Stack Operations
1.Push
2.Pop
3.Show
4.Exit
Enter your choice:1
Enter the item to push:1
Ex.No: 6
QUEUE OPERATIONS
AIM:
1. Insertion
2. Deletion
3. Modification
4. List
ALGORITHM:
Step 1:Declare one-dimensional array and an integer pointer variable and variables for insertion,
loops, option and size.
Step 3: The queue operation is performed using menu driven program and the menu includes a
number of choice.
Step 4: If the choice is 1, and it checks the condition whether the rear is equal to size and if it is
false then, else part is executed, i.e., it increments the rear and the new element is added.
Step 5: If the choice is 2, and it checks the condition whether the rear is equal to zero and if it is
false then, else part is executed, i.e., it will delete an element from the front of queue and the
remaining elements are moved one position front and rear is decremented.
Step 6: If the choice is 3, and it checks the condition whether the rear is equal to zero and if it is
false then, else part is executed, i.e., it lists the elements present in the queue.
Step 7: If the choice is 4, and it checks the condition whether the rear is equal to zero and if it is
false then, else part is executed, i.e., it replaces the element in the queue by the new element.
Step 8: If the choice is Invalid, then it displays the statement choose the correct option.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>//preprocessor directives
void main()
{
int *queue[15],q[15];
int n=0,i=0,opt,s=0,newval,size; //variable declaration
clrscr(); // clearing screen
printf("\n\t\t\t <=QUEUE OPERATIONS=>");
printf("\n\t\t\t ====================");
printf("\n\n Enter Size: ");
scanf("%d",&size); //To read size of queue
do
{
printf("\n\n\t MENU\n\t _______”);
printf(“\n\n\t 1.Insert"); // Displays menu
printf("\n\n\t 2.Delete\n\n\t 3.List\n\n\t 4.Modify\n\n\t 5.Exit");
printf("\n Enter your choice (1-5): ");
scanf("%d",&opt); //To read choice from menu
switch(opt)
{
case 1: // To insert an element
clrscr();
if(n==size) //If rear reaches maximum size then queue is full
printf("\n Queue Full");
else
{
n++; // Incrementing rear end
printf("\n Enter the new element: ");
scanf("%d",&q[n]); //read new element to insert
queue[n]=&q[n]; //new element is copied to queue
printf("\n The new element %d is added to queue",q[n]);
}
break;
case 2: // To delete an element
clrscr();
if(n==0) //If front is zero then queue empty
printf("\n Queue Empty");
else
{
printf("\n The Element %d is deleted",q[1]);
for(i=1;i<=n;i++)
{
*queue[i]=*queue[i+1]; //moving all elements one position front
}
queue[i]=0;
n--; // Decrementing rear end
}
break;
case 3: // To list the elements
if(n==0) //If front is zero then queue empty
printf("\n Queue is empty");
else
{
printf("\n Queue:(front)");
for(i=1;i<=n;i++) //To display the elements of queue
printf("%5d",*queue[i]);
printf(" (Rear)");
}
break;
case 4: //To modify the element of queue
if(n==0) //If front is zero then queue empty
printf("\n Queue Empty");
else
{
printf("\n Enter the position of element to be modified: ");
Re_enter:
scanf("%d",&s); //To read the position of queue
if(s>n) /*If position is greater than size of queue
it again pass the control to read valid position*/
{
printf("\n Enter position between [p1-%d]",n);
goto Re_enter;
}
printf("\n The element at %d is %d",s,*queue[s]);
printf("\n Enter new element: ");
scanf("%d",&newval); //Read the new element
*queue[s]=newval; //Insert the element in respective position
}
break;
case 5: //To exit from menu
exit(0);
default:
printf("\n Choose correct option");
}
}while(1);
}
TEST CASES:
OUTPUT :-
Enter Size: 3
MENU
1.Insert
2.Delete
3.List
4.Modify
5.Exit
Queue:(front) 77 3 (Rear)
Enter your choice (1-5): 5
Ex.No: 7
To test the C++ program: Palindrome string checking program using pointers.
ALGORITHM:
Step 1:Declare two variables s and r and two pointer variables strt and estr of any size.
Step 5: Using for loop, swap the variable to temporary variable ch.
Step 6: The values of s is assigned to pointer variable strt. The values of r are assigned to pointer
variable rstr.
Step 9: If the condition is true, display strt is not a palindrome, else display strt is a palindrome.
SOURCE CODE:
#include <iostream.h>
//#include <math.h>
#include <string.h>
#include <conio.h>
void main()
{
char original[20],reversed[20];
int length;
clrscr();
cout <<"Enter a string"<<endl;
cin>>original;
length=strlen(original);
strcpy(reversed,original);
for (int i=0;i<=length-1;i++)
{
reversed[length-1-i]=original[i];
}
cout <<original<<" "<<reversed<<endl;
if(strcmp(reversed,original)==0)
cout<<"It is a palindrome";
else
cout<<"It is not a palindrome";
getch();
}
TEST CASES:
TEST
TEST EXPECTED ACTUAL
- TEST STEPS STATUS
DESCRIPTION OUTPUT OUTPUT
ID
TC-01 To check the character Declare the character Character variable Character variable
SUCCESS
variable. variable. should be present. is present.
TC-02 To check the integer Declare the Integer Integer variable Integer variable is
SUCCESS
variable. variable. should be present. present.
TC-03 It should accept the
Enter the string. Accept the value. Value accepted. SUCCESS
value.
TC-04 Get the length of the String length is It should give the Produced the string
SUCCESS
string. calculated. string length. length.
TC-05 It should copy the Copied the string
Get duplicate copy of Copy the string from
string from original from original to SUCCESS
the string. original to reversed.
to reversed. reversed.
TC-06 It should produce
Check the reversed Fetch the reverse of Produce the string
the string in reverse SUCCESS
process statement. the string. in reverse order.
order.
TC-07 Check the both It should display Displayed
Both is same it is
variable original and ”IT IS ”IT IS SUCCESS
called palindrome.
reverse. PALINDROME”. PALINDROME”.
TC-08 Check the both It should display Displayed
Both is not same it is
variable original and “IT IS NOT A “IT IS NOT A SUCCESS
called palindrome.
reverse. PALINDROME”. PALINDROME”.
TC-09 Process case: Using for() loop The string Should The string is
SUCCESS
For() loop. reverse the string. be reversed. reversed.
TC-10 Check whether the if
Process case: SUCCESS
statement Both are Palindrome. Palindrome.
If condition.
not equal.
TC-11 Check whether the if
Process case:
statement Both are Not a palindrome. Not a palindrome. SUCCESS
If condition.
not equal.
OUTPUT :-
ENHANCEMENT:
Ex. No. 1:
AIM:
To develop test cases for theC++ program using white box testing: To find the week day
from a given date.
ALGORITHM:
Step 3: Using multi-way decision making statement, check the number given in variable n.
Step 4: If the given option is true, display the corresponding day given, else if the number is
invalid, display it as Invalid number.
Step 5: For the given decision making statement, develop the multiple condition coverage testing
for all cases.
1
SOURCE CODE:
#include<iostream>
#include<conio.h>
int main()
{
int n;
cout<<”Enter number for day: “;
cin>>n;
switch(n)
{
case 1: cout<<”Sunday”; break;
case 2:
cout<<”Monday”;
break;
case 3:
cout<<”Tuesday”;
break;
case 4:
cout<<”Wednesday”;
break;
case 5:
cout<<”Thursday”;
break;
case 6:
cout<<”Friday”;
break;
case 7:
cout<<”Saturday”;
break;
default:
cout<<”Invalid number!”;
break;
}
return 0;
}
TEST CASES:
TEST
TEST EXPECTED ACTUAL
- TEST STEPS STATUS
DESCRIPTION OUTPUT OUTPUT
ID
TC-01 To check the integer Declare the integer Integer variable Integer variable is
SUCCESS
variable. variable. should be present. present.
It should accept the
Enter the number. Accept the value. Value accepted. SUCCESS
TC-02 value.
Using Case structure Depends on the n
Process case:
TC-03 its checks the n value the day will Print the Day. SUCCESS
Case structure.
value. matched.
Using Case structure Depends on the n
Process case:
TC-04 its checks the n value the day will Invalid n value. FAILURE
Case structure.
value. matched.
TC-06 It should produce
Check the reversed Fetch the reverse of Produce the string
the string in reverse SUCCESS
process statement. the string. in reverse order.
order.
TC-07 Check the both It should display Displayed
Both is same it is
variable original and ”IT IS ”IT IS SUCCESS
called palindrome.
reverse. PALINDROME”. PALINDROME”.
TC-08 Check the both It should display Displayed
Both is not same it is
variable original and “IT IS NOT A “IT IS NOT A SUCCESS
called palindrome.
reverse. PALINDROME”. PALINDROME”.
TC-09 Process case: Using for() loop The string Should The string is
SUCCESS
For() loop. reverse the string. be reversed. reversed.
TC-10 Check whether the if
Process case: SUCCESS
statement Both are Palindrome. Palindrome.
If condition.
not equal.
TC-11 Check whether the if
Process case:
statement Both are Not a palindrome. Not a palindrome. SUCCESS
If condition.
not equal.
OUTPUT:
Enter number for day:1
Sunday
Ex. No. 2:
Scope:
The document only covers the requirements specifications for the Library Management
System. This document does not provide any references to the other component of the Library
Management System. All the external interfaces and the dependencies are also identified in
this document.
Feasibility study:
The overall scope of the feasibility study was to provide sufficient information to allow a
decision to be made as to whether the Library Management System project should proceed
and if so, its relative priority in the context of other existing Library Management Technology.
The feasibility study phase of this project had undergone through various steps which as
describe as under:
Identity the origin the information at different level.
Identity the expectation of user from computerized system.
Analyze the drawback of existing system(manual system)
Overview:
The implementation of Library Management starts with entering and updating master records
like book details, library information. Any further transaction like book issue, book return will
automatically update the current books.
Overall Description:
Product Perspective:
The proposed Library Management System will take care of the current book detail at any point
of time. The book issue, book return will update the current book details automatically so that
user will get the update current book details.
Product function:
The main purpose of this project is to reduce the manual work.
This software is capable of managing Book Issues, Returns, and Calculating/Managing Fine.
Generating various Reports for Record-Keeping according to end user requirements
User characteristics:
They have 2 levels of users
User module: In the user module, user will check the availability of the books.
Book return
Administration module: The following are the sub module in the administration module.
Register user
Entry book details
Book issue
General Constraints:
Any update regarding the book from the library is to be recorded to have update & correct
values.
Assumption and dependencies:
All the data entered will be correct and up to date. This software package is developed using
java as front end which is supported by sun micro system. Microsoft SQL server 2005 as the
back end which is supported by Window 7.
Specific Requirement:
External Interface Requirement:
The user should be simple and easy to understand and use. Also be an interactive
interface .The system should prompt for the user and administrator to login to the application
and for proper input criteria
User Interface:
The software provides good graphical interface for the user any administrator can operate on the
system, performing the required task such as create, update, viewing the details of the book.
Allows user to view quick reports like Book Issues/Returned etc in between particular time.
Stock verification and search facility based on different criteria.
Hardware interface:
Software interface :
Java language
Net beans IDE 7.0.1
MS SQL server 2005
Communication interface:
Window
Functional requirements:
Book entry: In this module we can store the details of the books.
Register student: in this module we can keep the details of the new student.
Book issue: This module is used to keep a track of book issue details.
Book return: This module enables to keep a track of return the books.
Performance requirements:
The capability of the computer depends on the performance of the software. The software can
take any number of inputs provided the database size is larger enough. This would depend on
the available memory space.
Design constraints :
Each member will be having a identity card which can be used for the library book issue, fine
payment etc. whenever library member wish to take a book, the book issued by the library
authority will be check both the book details as well as the student details and store it in library
database. In case of retrieval of book much of human intervention can be eliminated.
System attributes :
Maintainability: There will be no maintained requirement for the software. The database is
provided by the end user and therefore is maintained by this user.
Portability: The system is developed for secured purpose, so it is can’t be portable.
Availability: This system will available only until the system on which it is install, is
running.
Scalability: Applicable.