Latest

10/recent/ticker-posts

Sample Test Cases for 'for loop, switch case, do while loop, if else' Statements in Software Testing - STE 22518

Hello students, in the previous post we write Sample Test Cases for Notepad Software. In this post we provide "Sample Test Cases for 'for loop, switch case, do while loop, if else' Statements". To write sample test cases for for 'for loop, switch case, do while loop, if else' statements, you need to write Test Case ID, Objective, Prerequisites, Step Details, Input Data, Excepted Results, Actual Results, Status (Pass/Fail)
Lets see the sample test cases for for 'for loop, switch case, do while loop, if else' statements.
VIEW PDF
Test Case No. 1
TC-ID TC-1
Objective To check for loop iterations
Prerequisites Program for loop must be written, it should have valid for loop.
Step Details Write program having loop
 for( i=0; i<=10; i++)
 {
 printf("%d",i);
}
 Execute it.
Input Data N.A.
Expected Result for loop iterations must be correct and it should print value of i from 0 to 10
Actual Result It printed value of i from 0 to 10
Status Pass
Test Case No. 2
TC-ID TC-2
Objective To check for loop iterations
Prerequisites Program for loop must be written, it should have valid for loop.
Step Details Write program having loop
 for( i=0; i<=10; i++)
 {
 printf("%d",i);
}
 Execute it.
Input Data N.A.
Expected Result for loop iterations must be correct and it should print value of i from 0 to 10
Actual Result It does not print value of i from 0 to 10
Status Fail
Test Case No. 3
TC-ID TC-3
Objective To check switch case
Prerequisites Program for switch case must be written and it should have valid switch case
Step Details Write program having code
switch(ch)
{
case 1:
printf("This is case 1");
break;
case 2 :
printf("This is case 2");
break;
default:
printf(" Please enter correct choice");
}
Execute it.
Input Data Enter ch=1
Expected Result Case 1 must be executed and the case 1 must be printed
Actual Result Case 1 is executed and the case 1 is printed
Status Pass
Test Case No. 4
TC-ID TC-4
Objective To check switch case
Prerequisites Program for switch case must be written and it should have valid switch case
Step Details Write program having code
switch(ch)
{
case 1:
printf("This is case 1");
break;
case 2 :
printf("This is case 2");
break;
default:
printf(" Please enter correct choice");
}
Execute it.
Input Data Enter ch = 2
Expected Result Case 2 must be executed and the case 2 must be printed
Actual Result Case 2 is executed and the case 2 is printed
Status Pass
Test Case No. 5
TC-ID TC-5
Objective To check switch case
Prerequisites Program for switch case must be written and it should have valid switch case
Step Details Write program having code
switch(ch)
{
case 1:
printf("This is case 1");
break;
case 2 :
printf("This is case 2");
break;
default:
printf(" Please enter correct choice");
}
Execute it.
Input Data Enter ch = 2
Expected Result Case 2 must be executed and the case 2 must be printed
Actual Result Case 2 is not executed and the case 2 is not printed
Status Fail
Test Case No. 6
TC-ID TC-6
Objective To check do while loop
Prerequisites Program for do while must be written and it should have valid do while syntax
Step Details Write program having code
i=0;
do {
printf("%d",i);
i++
}
while(i<=10);
Execute it
Input Data N.A.
Expected Result It must print value of i from 0 to 10
Actual Result It printed value of i from 0 to 10
Status Pass
Test Case No. 7
TC-ID TC-7
Objective To check do while loop
Prerequisites Program for do while must be written and it should have valid do while syntax
Step Details Write program having code
i=0;
do {
printf("%d",i);
i++
}
while(i<=10);
Execute it
Input Data N.A.
Expected Result It must print value of i from 0 to 10
Actual Result It does not print value of i from 0 to 10
Status Fail
Test Case No. 8
TC-ID TC-8
Objective To check if else
Prerequisites Program for if else must be written and it should have valid if else syntax
Step Details Write program having code
Take input for a and b
if( a>b)
{
printf( " a is greater than b"); 
else
printf(" a is less than b");
}
Execute it 
Input Data a=10, b=20
Expected Result else part must be execute and a is less than b output must be print
Actual Result else part is executed and a is less than b output is printed
Status Pass
Test Case No. 9
TC-ID TC-9
Objective To check if else
Prerequisites Program for if else must be written and it should have valid if else syntax
Step Details Write program having code
Take input for a and b
if( a>b)
{
printf( " a is greater than b"); 
else
printf(" a is less than b");
}
Execute it 
Input Data a=20, b=10
Expected Result true part of if must be execute and a is greater than b must be print
Actual Result true part of if is executed and a is greater than b is printed
Status Pass
Test Case No. 10
TC-ID TC-10
Objective To check if else
Prerequisites Program for if else must be written and it should have valid if else syntax
Step Details Write program having code
Take input for a and b
if( a>b)
{
printf( " a is greater than b"); 
else
printf(" a is less than b");
}
Execute it 
Input Data a=20, b=10
Expected Result true part of if must be execute and a is greater than b must be print
Actual Result else part of if is executed and a is less than b is printed
Status Fail

Sample Test Cases for 'for loop, switch case, do while loop, if else' Statements PDF


Sample Test Cases for 'for loop, switch case, do while loop, if else' Statements in Software Testing - STE 22518

Post a Comment

0 Comments