Manual
Manual
1 Design, develop, code and run the program in c language to solve the commission
problem. Analyze it from the perspective of boundary value testing, derive different
test cases, execute these test cases and discuss the test results.
#include <stdio.h>
#include <stdlib.h>
int main() {
int locks, stocks, barrels, t_sales;
float commission;
// Display results
printf("The total sales is %d\n", t_sales);
printf("The commission is %.2f\n", commission);
return 0;
}
Design, develop, code and run the program in c language to implement the
2
NextDate function. Analyze it from the perspective of equivalence class value
testing, derive different test cases, execute these test cases and discuss the test
results.
#include <stdio.h>
int main() {
int d, m, y;
// Prompt the user to enter the date in MM DD YYYY format
printf("Enter today's date in the form of MM DD YYYY: ");
scanf("%d %d %d", &m, &d, &y);
// Check if the date is valid
if ((d < 1 || d > 31) || (m < 1 || m > 12) || (y < 1812 || y > 2030)) {
printf("Invalid date\n");
return 1;
}
// Handling months with 31 days
if ((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10) && d < 31) {
d++;
}
// End of months with 31 days
else if ((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10) && d == 31) {
d = 1;
m++;
}
// Handling months with 30 days
else if ((m == 4 || m == 6 || m == 9 || m == 11) && d < 30) {
d++;
}
// End of months with 30 days
else if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 30) {
d = 1;
m++;
}
// Handling December
else if (m == 12 && d < 31) {
d++;
}
// End of December
else if (m == 12 && d == 31) {
printf("%d is over\n", y);
d = 1;
m = 1;
y++;
}
// Handling February
else if (m == 2 && ((y % 4 != 0 && d < 28)||(y % 4 == 0 && d < 29))) {
d++;
}
// Handling end of February
else if (m == 2 && ((y % 4 != 0 && d == 28) || (y % 4 == 0 && d == 29))) {
d = 1;
m++;
}
// If February is invalid
else {
printf("Invalid date in February\n");
return 1;
}
// Print the next date
printf("Next date: %d-%d-%d\n", m, d, y);
return 0;
}
3 Design, develop, code and run the program in c language to solve the commission
problem. Analyze it from the perspective of decision table-based testing, derive
different test cases, execute these test cases and discuss the test results.
#include <stdio.h>
#include <stdlib.h>
int main() {
int locks, stocks, barrels, t_sales;
float commission;
// Display results
printf("The total sales is %d\n", t_sales);
printf("The commission is %.2f\n", commission);
return 0;
}
Design and develop a program in c language to solve the triangle problem defined as
follows: Accept three integers which are supposed to be the three sides of a triangle
4 and determine if the three values represent an equilateral triangle, isosceles
triangle, scalene triangle, or they do not form a triangle at all. Assume that the upper
limit for the size of any side is 10. Derive test cases for your program based on
boundary-value analysis, equivalence class partitioning and decision-table
approach and execute the test
cases and discuss the results.
#include <stdio.h>
int main()
{
int a, b, c;
#include <stdio.h>
int main()
{
int locks, stocks, barrels, tlocks = 0, tstocks = 0, tbarrels = 0;
float lprice = 45.0, sprice = 30.0, bprice = 25.0, sales, comm;
// Update totals
tlocks += locks;
tstocks += stocks;
tbarrels += barrels;
// Calculate sales
sales = (lprice * tlocks) + (sprice * tstocks) + (bprice * tbarrels);
printf("\nThe total sales = %.2f\n", sales);
// Calculate commission
if (t_sales <= 1000) {
commission = 0.10 * t_sales;
} else if (t_sales <= 1800) {
commission = 0.10 * 1000 + 0.15 * (t_sales - 1000);
} else {
commission = 0.10 * 1000 + 0.15 * 800 + 0.20 * (t_sales - 1800);
}
// Display commission
printf("The commission is = %.2f\n", comm);
return 0;
}
6 Design, develop, code and run the program in c language to implement the
binary search algorithm. Determine the basis paths and using them derive
different test cases, execute these test cases and discuss the test results.
#include <stdio.h>
int main()
{
int a[20], n, low, high, mid, key, i;
// Input elements
printf("Enter %d elements in ascending order:\n", n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
// Binary search
while (low <= high)
{
mid = (low + high) / 2;
if (a[mid] == key)
{
printf("Element found at position %d\n", mid + 1);
return 0;
} else if (a[mid] < key)
{
low = mid + 1;
} else
{
high = mid - 1;
}
}
return 0;
}