0% found this document useful (0 votes)
21 views44 pages

C Programming Basics: Functions & Tests

The document outlines several C programming exercises, including calculating the sum of individual digits, determining student results, generating prime numbers, and sorting arrays. Each exercise includes an aim, algorithm, coding example, output, and test cases to verify functionality. The programs have been executed and verified successfully.

Uploaded by

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

C Programming Basics: Functions & Tests

The document outlines several C programming exercises, including calculating the sum of individual digits, determining student results, generating prime numbers, and sorting arrays. Each exercise includes an aim, algorithm, coding example, output, and test cases to verify functionality. The programs have been executed and verified successfully.

Uploaded by

inbavel Murugan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

INDEX

S DATE NAMEOFTHEPROGRAM PAGENO


NO
01 SUMOFINDIVIDUALDIGITS

02 STUDENTRESULT

03 PRIMENUMBER

04 SORTINGBYUSINGARRAY

05 STACKOPERATION

06 QUEUEMANIPULATION

07 PALINDROME
1. SUMOFINDIVIDUALDIGITS

[Link]
DATE:

AIM:
Togetsumofindividualdigitsbycprogramusethefollowing.

ALGORITHM:
STEP1:Starttheprocess.
STEP2:Getnumberbyuser.
STEP3:Getthemodulus/remainderofthenumber.
STEP4:Sumtheremainderofthenumber.
STEP5:Dividethenumberby10
STEP6:Repeatthestep2whilenumberisgreaterthan0.
STEP7:Displaytheresult.
STEP8:Stoptheprocess.
CODING:

#include<stdio.h>
int main()
{
int n, sum=0,m;
printf(“Enter a number:”);
scanf(“%d”,&n);
while(n>0);
{
m=n%10;
sum=sum+m;
n=n/10;
}
printf(“Sum is =%d”,sum);
return 0;
}

OUTPUT:

Entera number:242 Sum


is =8
Entera number:123
Sum is=6
1. Test the C program: Finding the sumof individual digits of a 10-digit number until a single digitis
produced.

Test- Test TestSteps Expected Actual Status If Failure Resultafter New


Id Description Output Output (Success Correction Correction Status
/ Made
Failure)

TC-01 Acceptance Check Should Accepting success ----- ------ ------


of more whether accept thefirst10
than 10 12 Digit onlyfirst Digit
Digit data Numbers 10digits Numberof
are input
accepted
or not

TC-02 Non- Input a Character Warning& Success ------ ------ -----


acceptance character Shouldnot non-
ofcharacter Data be acceptance
data accepted. .

TC-03 Middlesum Display Sumvalue Sumvalue Success ------ ------ -----


values ifany sum at in stages
eachstage

TC-04 Displaying Actual Should Novalue Failure Move the Displaythe Success
givenvalue. Input printthe printed inputvalue value
should given to some
printalong Value variable x
withoutput
(Sum).

TC-05 Display Displaying EachDigit Nodigitis Failure Add a Displaythe Success


digits of digits in single printed statement digits
givenvalue individuall line. whichprints
y digits

TC-06 Should not Onlygiven ShouldNot Printsthe Failure Create a Onlygiven Success
print the digit print digits flag to digits
middlesum should be middlesum avoidthe displayed
digits displayed digits. digits
display
TC-07 Singledigit Checking Should Input is Failure Check the Display the Success
input withinput displaythe displayed input value message
as single it is single asoutput. greaterthan regarding
digit digit 9 and then singledigit.
proceed

TC-08 Zeroas When Display Accept Failure Check the Program Success
Input input is message input input value terminated
zero regarding without iszero;ifso
program input any stop the
should message program
stop.

TC-09 Negative Give a Shouldnot Signnot Success ----- ----- ----


Input negative accept accepted
value as
input

TC-10 Output on Output Outputon Outputas Success ----- ----- ----


freshscreen should Fresh expected.
contain Screen
onlyresult
withinput
activity.

RESULT:

Thustheprogramhasbeenexecutedandverifiedsuccessfully.
2. STUDENTRESULTS

[Link]
DATE:

AIM:
Todisplaythestudentsresultasrather“PASS”or“FAIL”.

ALGORITHM:
STEP1:Starttheprocess.
STEP2:Gettherequiredinputfromtheuser(Name&5subjectmarks).
STEP 3: Check the condition (i.e.) if all the 5 subject mark is greater than 40
Print the result as "PASS" else result as "FAIL".
STEP4:Displaythestudentresults.
STEP5:Stoptheprocess.
CODING:

#include<stdio.h>
#include<conio.h>
void main()
{
char name[20];int
s1,s2,s3,s4,s5;
clrscr();
printf("Enter the student name:");
scanf("%s",&name);
printf("Enter marks in five subjects \n");
printf("s1=");
scanf("%d",&s1);
printf("s2=");
scanf("%d",&s2);
printf("s3=");
scanf("%d",&s3);
printf("s4=");
scanf("%d",&s4);
printf("s5=");
scanf("%d",&s5);
if(s1<40 || s2<40 || s3<40 || s4<40 || s5<40)
printf("\n RESULT : FAIL");
else
printf("\nRESULT:PASS");
getch();
}
OUTPUT:

ENTER THE NAME OF THE STUDENT:


AFRIN
ENTER THE FIVE SUBJECT MARKS:
S1=089
S2=096
S3=100
S4=078
S5=088

RESULT:PASS

ENTER THE NAME OF THE STUDENT:


KALAIVANI
ENTER THE FIVE SUBJECT MARKS:
1=089
S2=096
S3=039
S4=078
S5=088

RESULT:FAIL
2. TesttheCprogram:AccepttheinputsstudentName,Marksforfivesubjectsanddeclare the result as
PASS if the student gets minimum 40 in each subject otherwise declare the resultas FAIL.

Test- Test TestSteps Expected Actual Status If Failure Resultafter New


Id Description Output Output (Success Correction Correction
/ Made Status
Failure)

TC-01 ResultTest Test “Pass” if “Pass” Success ------ ----- ------


for pass whether allsubject
result is marks >
passwhen 40
all values
are > 40

TC-02 ResultTest Test “Fail” if “Fail” Success ------ ----- ------


for fail whether anyoneor
resultisfail more than
withvalues subject
<40 marks <
40.

TC-03 Skipamark Skippinga Should Skipsthe Failure Check each Waitsfor Success
input or input value wait for values Input value value for
Zero as by pressing inputuntil with whether it positive
input value just enter value > 0 askingfor hasvalueor value
keyorZero entered positive not.
as value values.

TC-04 Null as Checkwhat Should Does not Failure CheckInput Waitsfor Success
inputfor happens askfor askname value of name
name when null name and namebefore
given as moves to moving to
input to mark mark input.
name input
process.

TC-05 Negative Check with Shouldnot Doesnot Success ------ ----- ------
Mark as negative accept the accept
input marks as mark. the
inputvalue. negative
value
TC-06 Maximum Checkwhat Shouldnot Accepts Failure Checkeach Askfornew Success
mark happens accept thevalue Input value mark if it
when input with exceeds100
value maximum
entered mark
greaterthan
maximum
value(Max:
100)

TC-07 Display Expectedto Ask to Doesnot Failure Addingthe Displaythe Success


markwith readsubject subject take coding to outputwith
subject name as name input for read the subject
name input subject name of name
subject.

TC-08 Skipsubject Nullvalue Shouldnot Accepts Failure Check Does not Success
name enter as accept the thename subjectname acceptthe
input for subject as null Input nullvalue
subject name as value&add as subject
name null conditionfor name
not
accepting
nullvalue

TC-09 If – Else Check Should Assigns Success ----- ----- -----


block whether assign the correctly.
checking. based on passorfail to
conditions res
theresultis identifier.
stored

RESULT:
Thustheprogramhasbeenexecutedandverifiedsuccessfully.
3. PRIMENUMBER

EXNO.:03
DATE:

AIM:
Togeneratenprimenumbers

ALGORITHM:

STEP1:Starttheprocess.
STEP2:Gettheinputvalueofnumber.
STEP3:Usingtheformula.
STEP 4: Calculation of the function.
STEP 5: Display the prime numbers.
STEP 6: Stop the process.
CODING:

#include<stdio.h>

#include<conio.h>

void main()

int i,j,n,s=0,flag=0;

clrscr();

printf("\n\n\t\t Generate prime numbers list");

printf("\n\n\t\t ***************************");

printf("\n\t Enter N values:");

scanf("%d",&n);

printf("\n\t The prime numbers are:\n\t");

for(i=1;i<n;i++)

flag=1;

for(j=2;j<i;j++)

if(i%j==0)

flag=0;

break;

}
}

if(flag)

printf("%d",i);

s++;

printf("\n\t The total prime numbers are:%d",s);

getch();

OUTPUT:

Enterthevalue:10
The prime numbers are: 1 2 3 5 7
The total prime numbers are: 5
3. TesttheCprogram:ProgramforgeneratingNprimenumbers.

Test- Test Test Expected Actual Status If Failure Resultafter New


Id Description Steps Output Output (Success Correction Correction
/ Made Status
Failure)

TC- Values Should Accepts Failure Check the Asknew Success


01 should ask the zero as inputvalue valuefor
Zero as beeither valueto input zero
inputvalue positive be
or
negative

TC- Check Forloop forloops Success ----- ----- -----


02 for loop should is
forloop executed execute working
properly properly

TC- Displaythe Check Should elements Failure Make Displayin Success


03 elementsin whether display are necessary row
row the the displayed changes to
elements element one by displayinrow
are in row one
displayed
inrowor
not

TC- flagvalue Values Should Accept Success ----- ----- -----


04 should acceptthe theflag
beeither flagvalue value
zero or zero or
one one

TC- Check If If Success ------ ----- ------


05 whether statement statement
Ifstatement the if should is
statement execute executes
is properly correctly
executed
or not
TC- header Check Without Without Success ----- ----- -----
06 status whether header,it header
headeris couldnot it’s not
working run working
or not

TC- Printf Check Without Without Success ----- ----- -----


07 statement whether printf printf
theprintf statement, statement,
is output outputnot
working shouldnot displayed
or not display

TC- Scanf Check Without Without Success ----- ----- -----


08 statement whether Scanf Scanf
thescanf statement statement,
is should input not
working not read getting.
or not input

RESULT:
Thustheprogramhasbeenexecutedandverifiedsuccessfully.
4. SORTINGBYUSINGARRAY

[Link]
DATE:

AIM:

Tocreatetwoarraylistofintegerssortandstoretheelementsofbothoftheminthird
list.

ALGORITHAM:
STEP1:Starttheprocess.
STEP2:Declarenecessaryheaderfileanddatatypes.
STEP3:Entertheelementsforfirstarray.
STEP4:Entertheelementsforsecondarray.
STEP5:Storetheelementsoffirstandsecondarrayintothirdarray.
STEP6:Sorttheelementsinthirdarray.
STEP7:Displaythesortedarray.
STEP8:Stoptheprocess.
CODING:

#include<studio.h>
#include<conio.h>
#include<math.h>
void main()
{
intm,n,p,sum=0;
int lista[5],listb[5],listc[10]={0};
clrscr();
printf("\nEnter Elements for First List:");
for(m=0;m<5;m++)
{
scanf("%d",&lista[m]);
if(lista[m]==0)m--;
sum=sum+abs(lista[m]);
}
printf("\nEnter Elements for Second List:");
for(n=0;n<5;n++)
{
scanf("%d",&listb[n]);
if(lista[n]==0)n--;
sum=sum+abs(listb[n]);
}
p=n=m=0;
m=m-sum;
while(m<sum)
{
for(n=0;n<5;n++)
{
if(m==lista[n] || m==listb[n])
listc[p++]=m;
if(m==lista[n] && m==listb[n])
listc[p++]=m;
}
m++;
}
puts("\nMerged Sorted List :");
for(n=0;n<10;++n)
printf("%d",listc[n]);
getch();
}

OUTPUT:

EnterElementsforFirstList :154-32

EnterElementsforSecondList 915215

MergedSortedList :-31122455915
4. TesttheCprogram:Sortandstoretheelementstwoarraysofintegersintothethirdlist.

Test- Test TestSteps Expected Actual Status If Failure Resultafter New


Id Description Output Output (Success Correction Correction
/ Made Status
Failure)

TC- Array Size Checkthe Should Doesnot Failure Check the Showsthe Success
01 valuecheck array size displaythe showthe input value message
inputwith Error and error whether
negative ask fornew >0otherwis
value value e show the
message as
“Incorrect
size”

TC- Condition Check All All Success ------ ----- -----


02 statement whether condition conditions
execution all the if should be are
statement executed working
are for all the fine.
executed bothcases
with true
and false
values

TC- Zeroasinput Value Shouldask Accepts Failure Checkthe Asknew Success


03 value should be the Zero as input valuefor
either valuetobe input values zero
positiveor reentered.
negative.

TC- Check For Checkfor Should Executes Success ------- ------ ------
04 loop for loop execute correctly
continuous executed the loop for all
operation correctly loops

TC- Interchanging Test Shouldnot Has a Failure Changethe Exchange Success


05 of values whether have variablefor coding and donewith
values temporary exchanging eliminate out extra
exchanged variable the values thevariable variable
without
using
temporary
variable
TC- Displaythe Displaying Should Display Failure Make Displaysin Success
06 elementsin theelement displaythe elements necessary row
row. of third element in onebyone changesto
array row display in
inarow row

TC- While Checking Should the Showthe Success ------ ----- ------
07 statement the while message Message
execution statement for non
withinput acceptance
valuezero ofzero.

TC- Arraylimit Check Shouldnot Does not Failure Check the Showsthe Success
08 what accept anyshow arrayinput massage
happens when size message size with
whensize is greater and maximum
of array than 10. produces limit
exceeds incorrect
than its result
limit.

TC- Final list Check Should Condition Success ----- ----- -----
09 arraysize whether accept satisfied
limit both whentotal
elements of array 1
can be and2size is
storedin less or
third equalto
array. 20.

RESULT:
Thustheprogramhasbeenexecutedandverifiedsuccessfully.
5. STACKOPERATION

[Link]
DATE:

AIM:
ToexperimentintheoperationofSTACKusingarrayimplementation.

ALGORITHM:
STEP1:Starttheprocess.
STEP2:Definethesizeofthestack.
STEP3:Inputthechoice,usingINSERTorDELETE.
STEP4:Ifchoice=“INSERT”thengotoSTEP5elsegotoSTEP10.
STEP 5: Check if the stack is full then display “STACK IS FULL” go
to STEP else go to STEP 6.
STEP6:InitializeTOP=0inputtheelementandassignittoTOP.
STEP 7: Increment the TOP by ONE.
STEP 8: Display the element of stack.
STEP 9: Go to STEP 13.
STEP 10: Check if the STACK IS EMPTY [no elements in stack] then
display “EMPTY STACK” else go to STEP 11.
STEP 11: Decrement the TOP by ONE.
STEP 12: Display the elements in the stack.
STEP 13: Stop the process.
CODING:

#include<stdio.h>
#include<conio.h>
void insert();
void
del();Voiddispl
ay();
int stack[50],p,s;
void main()
{
int ch;
clrscr();
printf("\n\n\n\tSTACKOPERATION");
printf("\n\n\nEnter The Stack Size Of Stack(max_len50):"); scanf("%d",&s);
if(s>=1&&s<=50)
{
while(1)
{
clrscr();
printf("\n\n\t\t STACK OPERATION"); printf("\n\n\
t\t MENU");
printf("\n\n\t [Link]\n\n\t [Link] \n\n\t [Link]\n\n\t [Link]"); printf("\
n\n\tEnter Your Choice:");
scanf("%d",&ch);
switch(ch)
{
case1:
insert();
break;
case2:
del();
break;
case3:
display();
break;
case4:
exit();
default:
printf("\n\n\tInvalidChoice");
}
getch();
}
}
else
printf("\n\n\tInvalid Data");
getch();
}
voidinsert()
{
if(p==s)
printf("\n\n\tSTACK IS FULL"); else
{ p+
+;
printf("\n\n\tEnter An Element:");
scanf("%d", & stack[p]);
}
}
voiddel()
{
if(p==0)
printf("\n\n\tNo Elements in Stack to Delete"); else
{
printf("\n\n\tThe Deleted Element is %d",stack[p]);
p--;
}
}
voiddisplay()
{
int i;
if(p==0)
printf("\n\n\tSTACK IS EMPTY");
else
{
for(i=1;i<=p;i++) printf("\n\n\t
%d\n",stack[i]);
}
}
OUTPUT:

STACKOPERATION

EnterTheStackSizeofStack(max_len50):30

STACKOPERATION

MENU
1. Insert
2. Delete
3. Display
4. EXIT
EnterYourChoice:1
EnterAnElement:100

STACKOPERATION

MENU
1. Insert
2. Delete
3. Display
4. EXIT
EnterYourChoice:1
EnterAnElement:200

STACKOPERATION

MENU
1. Insert
2. Delete
3. Display
4. EXIT
EnterYourChoice:1
EnterAnElement:300

STACKOPERATION

MENU
1. Insert
2. Delete
3. Display
4. EXIT
Enter Your Choice: 3
100
200
300

STACKOPERATION

MENU
1. Insert
2. Delete
3. Display
4. EXIT
EnterYourChoice:2
TheDeletedElementis:300

STACKOPERATION
MENU
1. Insert
2. Delete
3. Display
4. EXIT
Enter Your Choice: @
Invalid Choice

STACKOPERATION

MENU
1. Insert
2. Delete
3. Display
4. EXIT
EnterYourChoice:4
1. TesttheCprogram:ExperimenttheoperationsofSTACKusingarrayimplementation.

Test- Test Test Expected Actual Status If Failure Resultafter New


Id Description Steps Output Output (Success Correction Correction
/ Made Status
Failure)

TC- Negative Giventhe Indication Show Success ------ ----- -----


01 StackSize negative of Error Error
value for
stacksize

TC- Character Type Shouldan Doesnot Failure Place the Shows the Success
02 input to character the error showthe coding errorwhen
choice input for that it is error. which incorrect
operation incorrect checkthe input
selection value choice
input is
number
value.

TC- Stack Checking Stackfull Message Success ----- ------ ------


03 Overflow the message displayed
overflow shouldbe correctly
condition displayed
ofstack

TC- [Link] Should Empty Doesnot Failure Find the Showsthe Success
04 empty showthe Spacein showthe numberof numbers
position number stack numbers empty
ofempty space and
position show the
of stack numbers
while
elements
of stack
listed.

TC- Stack Checking Stack Message Success ----- ------ ------


05 underflow the empty displayed
underflow message correctly
condition shouldbe
of stack displayed
(Stack
empty)
TC- [Link] Should Number Doesnot Failure Find the Showsthe Success
06 remaining show the of showthe numberof number
element numberof Elements numbers elements
remaining in stack can be
elements can be stored in
after pop stored. stackand
operation. show the
number

TC- Condition Check All All Success ------ ----- -----


07 statement whether condition conditions
execution all the if shouldbe are
statement executed working
are forallthe fine.
executed bothcases
with true
and false
values

TC- Check Check Should Works Failure Make the Worksfor Success
08 Whileloop while acceptthe onlyfor necessary bothcases
for loop user “y”. changes to
continuous executed choice y work on
operation when (or) Yand bothcases.
there execute
valuefor theloop
chisyes.

TC- Checkfor Stack Shouldnot Accept Failure Check the Negative Success
09 non- should acceptthe the inputvalue valuenot
negative acceptthe elements element for non- accepted
elements positive negative
elements value.

TC- Verify all Check all Should Choice 4 Failure Make the Exitswhen success
10 userchoice theoptions work on does not necessary 4 is
withinput the basis exitsfrom coding selected
values ofchoice operation changes

RESULT:
Thustheprogramhasbeenexecutedandverifiedsuccessfully.
6. QUEUEMANIPULATION

[Link]
DATE:

AIM:
TocreatemenudriveprogramtoimplementQUEUEtoperformthefollowing.
INSERTION
DELETION
MODIFICATION
LISTINGOFELEMENTSUSINGPOINTERS

ALGORITHM:
STEP1:Starttheprocess.
STEP 2: Input the choice if CHOICE =1(add) go to STEP 3 else if
CHOICE=2(del) go to STEP 5 else if CHOICE=3(modify) else go to
(list).
STEP 3: Initialize REAR= -1 & FRONT=0 check QUEUE OVERFLOW & if no
overflow occurs then get the number to be stored.
STEP4:IncrementREARbyONE&storethenumberinthereargotoSTEP8.
STEP5:IncrementFRONTbyONEgotoSTEP8.
STEP6:Getthenumbertobemodified.
STEP7:Searchthegivennumberbyusingthepointerandgetandassignit.
STEP8:DisplaytheelementintheQUEUE.
STEP9:Stoptheprocess.
CODING:

#include<stdio.h>
#include<conio.h>
#define max 4
#define ture 1
intqueue[max];
int rear=-1,front=0;
void main()
{
int
ch;voidadd
();
voiddel();
voidmodify();
void list();
while(1)
{
clrscr();
printf("\n\tQUEUE MAINPULATION");
printf("\n\t.....................");
printf("\nMAIN MENU");
printf("\n..........");
printf("\n1].ADD");
printf("\n2].DELETE");
printf("\n3].MODIFY");
printf("\n4].LIST");
printf("\n5].EXIT");
printf("\nENTERYOURCHOICE:::>");
scanf("%d",&ch);
switch(ch)
{
case 1:add();break;
case 2:del();break;case
3:modify();break;
case4:list();break;
case 5:printf("\nPROGRAM IS TERMINATED");
getch();
exit(0);
break;
}
}
}

voidadd()
{
intx;
printf("\nENTERTHENUMBERTOADD::::>");
scanf("%d",&x);
if(rear>=max-1)
printf("\nQUEUE OVERFLOW");
else
{
rear++;queue[rear]=x;
printf("\n%dISSUCCESSFULLYADDED",x);
}
getch();
}

voiddel()
{
int x;
if(front>rear)
printf("\nQUEUEUNDERFLOW");
else
{
x=queue[front];front++;
printf("\n%dISSUCCEESSFULLYDELETE",x);
}
getch();
}

voidmodify()
{
intx,y,i,flag=0;
int *p;
if(front>rear)
printf("\nQUEUE IS EMPTY");
else
{
p=&queue[front];
printf("\nENTERTHENUMBERTOMODIFY:");
scanf("%d",&x);
i=front;
while(i<=rear)
{
if(*p==x)
{
flag=1;
printf("\nENTERTHENEWNUMBERTOMODIFY:");
scanf("%d",&y);
*p=y;
printf("\nNUMBERISSUCCESSFULLYMODIFY");
break;
}
p++;
i++;
}
if(flag==0)
printf("\nNUMBERNOTFOUND");
}
getch();
}
voidlist()
{
int i;
if(front>rear)
printf("\nQUEUE IS EMPTY");
else
{
printf("\n\t%d...>rear",queue[rear]);
for(i=rear-1;i>front;i--) printf("\n\t
%d",queue[i]); printf("\n\t
%d...>front",queue[front]);
}
getch();
}
OUTPUT:

QUEUEMAINPULATION
..........................................
MAINMENU
…………......
1].ADD
2].DELETE
3].MODIFY
4].LIST
5].EXIT

ENTERYOURCHOICE:::>1
ENTER THE NUMBER TO ADD ::::> 10
10 IS SUCCESSFULLY ADDED

1].ADD
2].DELETE
3].MODIFY
4].LIST
5].EXIT

ENTERYOURCHOICE:::>1
ENTER THE NUMBER TO ADD ::::> 20
20 IS SUCCESSFULLY ADDED

1].ADD
2].DELETE
3].MODIFY
4].LIST
5].EXIT
ENTERYOURCHOICE:::>1
ENTER THE NUMBER TO ADD ::::> 30
30 IS SUCCESSFULLY ADDED
1].ADD
2].DELETE
3].MODIFY
4].LIST
5].EXIT

ENTERYOURCHOICE:::>4
30...>rear
20
10...>front

1].ADD
2].DELETE
3].MODIFY
4].LIST
5].EXIT

ENTERYOURCHOICE:::>3
ENTER THE NUMBER TO MODIFY : 20
ENTER THE NEW NUMBER TO MODIFY : 25
NUMBER IS SUCCESSFULLY MODIFY

1].ADD
2].DELETE
3].MODIFY
4].LIST
5].EXIT
ENTERYOURCHOICE:::>5
PROGRAMISTERMINATED
6. TesttheCprogram:Menu-drivenoptionforQUEUEoperations.

Test- Test Test Expected Actual Status If Failure Resultafter New


Id Description Steps Output Output (Success Correction Correction
/ Made Status
Failure)

TC- Negative Giventhe Indication Show Success ------ ----- -----


01 QueueSize negative of Error Error
value for
queuesize

TC- Character Type Shouldan Doesnot Failure Place the Shows the Success
02 input to character the error showthe coding errorwhen
choice input for that it is error. which incorrect
operation incorrect checkthe input
selection value choice
input is
number
value.

TC- QueueFull Checking Queuefull Message Success ----- ------ ------


03 the Full message displayed
condition shouldbe correctly
of queue displayed

TC- [Link] Should Empty Doesnot Failure Find the Showsthe Success
04 empty showthe Spacein showthe numberof numbers
position number Queue numbers empty
ofempty space and
position show the
of queue numbers
while
elements
listed.

TC- Queue Checking Queue Message Success ----- ------ ------


05 Empty theempty empty displayed
condition message correctly
of queue. shouldbe
displayed
TC- [Link] Should Number Doesnot Failure Find the Showsthe Success
06 remaining show the of showthe number of number
element in numberof Elements numbers elementsin
Queueafter remaining in Queue queue can
deletion elements can be be stored
after stored and show
deletion thenumber
operation.

TC- Condition Check All All Success ------ ----- -----


07 statement whether condition conditions
execution all the if shouldbe are
statement executed working
are forallthe fine.
executed bothcases
with true
and false
values

TC- Check Check Should Works Failure Make the Worksfor Success
08 Whileloop while acceptthe onlyfor necessary bothcases
for loop user “y”. changes to
continuous executed choice y work on
operation when (or) Yand bothvalues
there execute (Y or y).
value for the loop
chisyes.

RESULT:
Thustheprogramhasbeenexecutedandverifiedsuccessfully.
7. PALINDROME

[Link]
DATE:

AIM:
Tocreatepalindromestringcheckingprogram(UsingPointers).

ALGORITHAM:

STEP1:Starttheprocess.
STEP2:GetastringandusingPointer.
STEP3:Findthelivesofthegivenstringandstartedinptr2.
STEP4:Usingwhile()andifstatements.
STEP5:Ifptr1&ptr2aresamethenprintTheStringisPalindrome.
STEP6:ElseprintTheStringisnotPalindrome
STEP7:Stoptheprocess.
CODING:

#include<iostream.h>
#include<conio.h>
void main()
{
int con,len=0;
char*name,*p;
p=name;
clrscr();
cout<<"\n\nEnter a String:";
cin>>name;
while(*p!='\0')
{
len++; p+
+;
}
len-=1;
p=name;
while(*p!='\0')
{
if(*p==name[len])
con=1;
else
{
con=0;
break;
} p+
+;
len--;
}
if(con==1)
cout<<"\n\n The String is Palindrome";
else
cout<<"\n\nThe String is not Palindrome";
getch();
}

OUTPUT:

EnteraString:RACECAR

TheStringisPalindrome

EnteraString:KARTHICK

TheStringisnotPalindrome
7. TesttheC++Program:Palindromestringcheckingprogram.(usingPointers)

Test- Test TestSteps Expected Actual Status If Failure Resultafter New


Id Description Output Output (Success Correction Correction
/ Made Status
Failure)

TC- Single Check the Should No Failure Checkthe Checksthe Success


01 Character withsingle given Warning length of length and
input characteras warning is given the input gives
input and warning
proceed
with
process

TC- Condition Check All All Success ------ ----- -----


02 statement whetherall condition conditions
execution the if should be are
statement executed working
are for all the fine.
executed bothcases
with true
and false
values

TC- Arraylimit Check Should No Failure Checkthe Checksthe Success


03 what given Warning length of length and
happens warning is given the input gives
when and array warning
string limit
length
exceeds
maximum
limit of
array.

TC- Check For Checkfor Should Executes Success ------- ------ ------
04 loop for loop executethe correctly
continuous executed loop for all
operation correctly loops

TC- Checkthe Check Should Changes Success ------ ------ -----


05 flagstatus whetherflag change to aremade
fstatus 0 if correctly
changes characters
correctly do not
match
TC- Checkinput In the final Shouldthe Doesnot Failure Changethe Displaysthe -----
06 value output givenvalue showthe coding to givenvalue
display givenvalue given display
should be value. the given
displayed value

TC- Continue Checking Should Executes Success ----- ----- ------


07 statement whether execute correctly
working the correctly
continue
statement
executed
correctly

TC- Palindrome Check Should Check Success ----- ----- ------


08 Checking whether compare character
method character character one by
comparison for one.
is made palindrome

TC- Arrayindex Check the By default Starts Success ------ ---- -----
09 arrayindex it should with0
starting startwith0
value

RESULT:
Thustheprogramhasbeenexecutedandverifiedsuccessfully.

You might also like