0% found this document useful (0 votes)
4 views31 pages

Maximum of Three Numbers Program

The document outlines three experiments aimed at finding the maximum of three user-input numbers using different testing approaches: Boundary Value Analysis, Robust Approach, and Worst Boundary Value. Each experiment includes a source code written in C++ and describes the process of generating test cases based on the specified approach. The experiments are authored by Aman Gupta, with a focus on implementing and testing the maximum finding functionality.

Uploaded by

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

Maximum of Three Numbers Program

The document outlines three experiments aimed at finding the maximum of three user-input numbers using different testing approaches: Boundary Value Analysis, Robust Approach, and Worst Boundary Value. Each experiment includes a source code written in C++ and describes the process of generating test cases based on the specified approach. The experiments are authored by Aman Gupta, with a focus on implementing and testing the maximum finding functionality.

Uploaded by

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

‭EXPERIMENT - 1‬

‭AIM‬‭: -‬‭Write a program to find the maximum in three‬‭numbers input by the user and generate‬
‭test cases for the program using‬‭Boundary Value Analysis.‬

‭SOURCE CODE‬‭: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

‭int‬‭main‬‭(){‬
‭int‬‭n‬‭;‬
‭cin‬‭>>‬‭n‬‭;‬
‭vector‬‭<‭p ‬ air‬‭<‬‭int‬‭,‬‭int‬‭>>‬‭scope‬‭;‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭result‬‭;‬
‭cout‬‭<<‬‭"‭E
‬ nter No. of variables:-‬‭";‬

‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭n‬‭;‬‭i‭+
‬ +){‬
‭int‬‭a‬‭,‬‭b‬‭;‬
‭cin‬‭>>‬‭a‬‭>>‬‭b‬‭;‬
‭cout‬‭<<‬‭"‭E ‬ nter Range:-‬‭";‬
‭scope‬‭.‬‭push_back‬‭(‬‭{‭a‬ ‬‭,‬‭b‬‭}‭)‬ ;‬
‭}‬

‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬


‭vector‬‭<‬‭int‬‭>‬‭temp‬‭(‬‭n‬‭);‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‬‭4‬‭;‬‭j‭+ ‬ +){‬
‭for‬‭(‬‭int‬‭k‬‭=‬‭0‬‭;‬‭k‬‭<‬‭n‬‭;‬‭k‬‭++){‬
‭if‬‭(‭i‬‬‭!=‬‭k‬‭){‬
‭temp‬‭[‭k‬ ‬‭]‬‭=‬‭(‭s‬ cope‬‭[‭k‬ ‬‭]‬‭.‬‭first‬‭+‭s‬ cope‬‭[‬‭k‬‭]‭.‬‬‭second‬‭)/‬‭2‬‭;‬
‭}‬
‭else‬‭{‬
‭if‬‭(‭j‬‬‭==‬‭0‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭first‬‭;‬
‭else‬‭if‬‭(‭j‬‬‭==‬‭1‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭first‬‭+‬‭1‬‭;‬
‭else‬‭if‬‭(‭j‬‬‭==‬‭2‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭second‬‭-‭1‬ ‬‭;‬
‭else‬‭temp‬‭[‭k‬ ‬‭]‬‭=‬‭scope‬‭[‬‭i‭]‬ ‬‭.‬‭second‬‭;‬
‭}‬
‭}‬
‭result‬‭.‬‭push_back‬‭(‭t‬emp‬‭);‬
‭}‬
‭}‬
‭vector‬‭<‭i‬nt‬‭>‬‭temp‬‭(‬‭n‬‭);‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭temp‬‭[‬‭i‬‭]‬‭=‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭+‬‭scope‬‭[‭i‬‭]‬ ‬‭.‬‭second‬‭)/‬‭2‬‭;‬
}‭ ‬
‭result‬‭.‬‭push_back‬‭(‭t‬emp‬‭);‬
‭cout‬‭<<‬‭"‭S ‬ .No.‬‭"‭< ‬ <‬‭"‬‭";‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭cout‬‭<<‬‭"‬‭Variable‬‭"‭< ‬ <‬‭i‭+
‬ ‬‭1‬‭<<‬‭"‬‭";‬
‭}‬
‭cout‬‭<<‬‭"‬‭Output‬‭";‬
‭cout‬‭<<endl‬‭;‬
‭int‬‭tc‬‭=‬‭1‬‭;‬
‭for‬‭(‬‭auto‬‭i‭:‬‬‭result‬‭){‬
‭cout‬‭<<setw‬‭(‭5‬ ‬‭)‬‭<<‬‭tc‬‭;‬
‭tc‬‭++;‬
‭int‬‭maxi‬‭=‬‭INT_MIN‬‭;‬
‭for‬‭(‬‭auto‬‭j‭:‬‬‭i‭)‬ {‬
‭maxi‬‭=‬‭max‬‭(‬‭maxi‬‭,‬‭j‬‭);‬
‭cout‬‭<<setw‬‭(‭1‬ 1‬‭)‬‭<<‬‭j‬‭;‬
‭}‬
‭cout‬‭<<setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭maxi‬‭;‬
‭cout‬‭<<endl‬‭;‬
‭}‬
‭}‬

‭OUTPUT‬‭: -‬
‭EXPERIMENT - 2‬

‭AIM‬‭: -‬‭Write a program to find the maximum in three‬‭numbers input by the user and generate‬
‭test cases for the program using‬‭Robust Approach.‬

‭SOURCE CODE‬‭: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬
‭int‬‭main‬‭(){‬
‭int‬‭n‬‭;‬
‭cin‬‭>>‬‭n‬‭;‬
‭vector‬‭<‭p‬ air‬‭<‬‭int‬‭,‬‭int‬‭>>‬‭scope‬‭;‬
‭cout‬‭<<‬‭"‭E ‬ nter No. of variables:-‬‭";‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭cout‬‭<<‬‭"‭E ‬ nter Range:-‬‭";‬
‭int‬‭a‬‭,‬‭b‬‭;‬
‭cin‬‭>>‬‭a‭> ‬ >‬‭b‬‭;‬
‭scope‬‭.‬‭push_back‬‭(‭{‬ ‬‭a‭,‬‬‭b‬‭}‬‭);‬
‭}‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭result‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭vector‬‭<‬‭int‬‭>‬‭temp‬‭(‬‭n‬‭);‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‭6‬ ‬‭;‬‭j‭+ ‬ +){‬
‭for‬‭(‬‭int‬‭k‬‭=‬‭0‬‭;‬‭k‬‭<‬‭n‬‭;‬‭k‬‭++){‬
‭if‬‭(‭i‬‬‭!=‬‭k‬‭){‬
‭temp‬‭[‭k‬ ‬‭]‬‭=‬‭(‭s‬ cope‬‭[‭k‬ ‬‭]‬‭.‬‭first‬‭+‭s‬ cope‬‭[‬‭k‬‭]‭.‬‬‭second‬‭)/‬‭2‬‭;‬
‭}‬
‭else‬‭{‬
‭if‬‭(‭j‬‬‭==‬‭0‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭first‬‭-‭1‬ ‬‭;‬
‭else‬‭if‬‭(‭j‬‬‭==‬‭1‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭first‬‭;‬
‭else‬‭if‬‭(‭j‬‬‭==‬‭2‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭first‬‭+‬‭1‬‭;‬
‭else‬‭if‬‭(‭j‬‬‭==‬‭3‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭second‬‭-‭1‬ ‬‭;‬
‭else‬‭if‬‭(‭j‬‬‭==‬‭4‬‭)‬‭temp‬‭[‬‭k‬‭]‬‭=‬‭scope‬‭[‭i‬‬‭]‭.‬‬‭second‬‭;‬
‭else‬‭temp‬‭[‭k‬ ‬‭]‬‭=‬‭scope‬‭[‬‭i‭]‬ ‬‭.‬‭second‬‭+‬‭1‬‭;‬
‭}‬
‭}‬
‭result‬‭.‬‭push_back‬‭(‬‭temp‬‭);‬
‭}‬
‭}‬
‭vector‬‭<‭i‬nt‬‭>‬‭temp‬‭(‬‭n‬‭);‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭temp‬‭[‬‭i‬‭]‬‭=‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭+‬‭scope‬‭[‭i‬‭]‬ ‬‭.‬‭second‬‭)/‬‭2‬‭;‬
}‭ ‬
‭result‬‭.‬‭push_back‬‭(‬‭temp‬‭);‬
‭cout‬‭<<‬‭"‭S ‬ .No.‬‭"‭< ‬ <‬‭"‬‭";‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭cout‬‭<<‬‭"‬‭Variable‬‭"‭< ‬ <‬‭i‭+
‬ ‬‭1‬‭<<‬‭"‬‭";‬
‭}‬
‭cout‬‭<<‬‭"‬‭Output‬‭";‬
‭cout‬‭<<endl‬‭;‬
‭int‬‭tc‬‭=‬‭1‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭r‬ esult‬‭.‬‭size‬‭();‬‭i‭+ ‬ +){‬
‭cout‬‭<<setw‬‭(‭5‬ ‬‭)‬‭<<‬‭tc‬‭;‬
‭tc‬‭++;‬
‭int‬‭maxi‬‭=‬‭INT_MIN‬‭;‬
‭for‬‭(‬‭auto‬‭j‭:‬‬‭result‬‭[‬‭i‭]‬ ‭)‬ {‬
‭maxi‬‭=‬‭max‬‭(‬‭maxi‬‭,‬‭j‬‭);‬
‭cout‬‭<<setw‬‭(‭1‬ 1‬‭)‬‭<<‬‭j‭;‬‬
‭}‬
‭if‬‭(‬‭i‭=
‬ =‬‭6‬‭*‬‭n‬‭)‬‭cout‬‭<<setw‬‭(‬‭10‬‭)‭< ‬ <‬‭maxi‬‭;‬
‭else‬‭if‬‭(‭i‬‬‭%(‬‭2‬‭*‬‭n‬‭)==‬‭0‬‭||‬‭i‭%
‬ (‬‭2‬‭*‬‭n‬‭)==((‬‭2‬‭*‬‭n‬‭)-‬‭1‬‭))‬‭cout‬‭<<‬‭"‬‭ InValid‬‭";‬
‭else‬‭cout‬‭<<setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭maxi‬‭;‬
‭cout‬‭<<endl‬‭;‬
‭}‬
‭}‬

‭OUTPUT: -‬
‭EXPERIMENT - 3‬

‭AIM‬‭: -‬‭Write a program to find the maximum in three‬‭numbers input by the user and generate‬
‭test cases for the program using‬‭Worst Boundary Value‬‭.‬

‭SOURCE CODE‬‭: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

v‭ oid‬‭patterns‬‭(‭i‬nt‬‭i‭,‬‬‭vector‬‭<‬‭int‬‭>‬‭&‬‭temp‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭&‭c‬ ases‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭&‬
‭result‬‭){‬
‭if‬‭(‬‭i‭= ‬ =‬‭cases‬‭.‬‭size‬‭()){‬
‭result‬‭.‬‭push_back‬‭(‭t‬emp‬‭);‬
‭return‬‭;‬
‭}‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‭5‬ ‬‭;‬‭j‭+ ‬ +){‬
‭temp‬‭.‬‭push_back‬‭(‬‭cases‬‭[‭i‬‬‭][‬‭j‭]‬ ‭)‬ ;‬
‭patterns‬‭(‬‭i‭+ ‬ ‬‭1‬‭,‬‭temp‬‭,‬‭cases‬‭,‬‭result‬‭);‬
‭temp‬‭.‬‭pop_back‬‭();‬
‭}‬
‭}‬
‭int‬‭main‬‭(){‬
‭cout‬‭<<‬‭"‭E ‬ nter No. of variables:-‬‭";‬
‭int‬‭n‬‭;‬
‭cin‬‭>>‬‭n‬‭;‬
‭vector‬‭<‭p ‬ air‬‭<‬‭int‬‭,‬‭int‬‭>>‬‭scope‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭cout‬‭<<‬‭"‭E ‬ nter Range:-‬‭";‬
‭int‬‭a‬‭,‬‭b‬‭;‬
‭cin‬‭>>‬‭a‭> ‬ >‬‭b‬‭;‬
‭scope‬‭.‬‭push_back‬‭(‬‭{‭a‬ ‬‭,‬‭b‬‭}‭)‬ ;‬
‭}‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭cases‬‭(‬‭n‬‭);‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭+‬‭1‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭((‬‭scope‬‭[‭i‬‭]‬ ‬‭.‬‭first‬‭+‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭)/‬‭2‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭-‬‭1‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭);‬
‭}‬‭‬
‭vector‬‭<‭i‬nt‬‭>‬‭temp‬‭;‬
v‭ ector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭result‬‭;‬
‭patterns‬‭(‬‭0‬‭,‬‭temp‬‭,‬‭cases‬‭,‭r‬ esult‬‭);‬
‭cout‬‭<<‬‭"‭S ‬ .No.‬‭"‭< ‬ <‬‭"‬‭";‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‭n‬ ‬‭;‬‭i‭+ ‬ +){‬
‭cout‬‭<<‬‭"‬‭Variable‬‭"‭< ‬ <‬‭i‭+
‬ ‬‭1‬‭<<‬‭"‬‭";‬
‭}‬
‭cout‬‭<<‬‭"‬‭Output‬‭";‬
‭cout‬‭<<endl‬‭;‬
‭int‬‭tc‬‭=‬‭1‬‭;‬
‭for‬‭(‬‭auto‬‭i‭:‬‬‭result‬‭){‬
‭cout‬‭<<setw‬‭(‭5‬ ‬‭)‬‭<<‬‭tc‬‭;‬
‭tc‬‭++;‬
‭int‬‭maxi‬‭=‬‭INT_MIN‬‭;‬
‭for‬‭(‬‭auto‬‭j‭:‬‬‭i‭)‬ {‬
‭maxi‬‭=‬‭max‬‭(‬‭maxi‬‭,‬‭j‬‭);‬
‭cout‬‭<<setw‬‭(‭1‬ 1‬‭)‬‭<<‬‭j‬‭;‬
‭}‬
‭cout‬‭<<setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭maxi‬‭;‬
‭cout‬‭<<endl‬‭;‬
‭}‬
‭}‬

‭OUTPUT‬‭: -‬
‭EXPERIMENT - 4‬

‭AIM‬‭: -‬‭Write a program to find the maximum in three‬‭numbers input by the user and generate‬
‭test cases for the program using‬‭Worst Robust Approach‬‭.‬

‭SOURCE CODE‬‭: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

v‭ oid‬‭patterns‬‭(‭i‬nt‬‭i‭,‬‬‭vector‬‭<‬‭int‬‭>‬‭&‬‭temp‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭&‬‭cases‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭&‬
‭result‬‭)‬‭{‬
‭if‬‭(‬‭i‬‭==‬‭cases‬‭.‬‭size‬‭())‬‭{‬
‭result‬‭.‬‭push_back‬‭(‭t‬emp‬‭);‬
‭return‬‭;‬
‭}‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‬‭7‬‭;‬‭j‭+
‬ +)‬‭{‬
‭temp‬‭.‬‭push_back‬‭(‬‭cases‬‭[‭i‬‬‭][‬‭j‭]‬ ‭)‬ ;‬
‭patterns‬‭(‬‭i‬‭+‬‭1‬‭,‬‭temp‬‭,‬‭cases‬‭,‬‭result‬‭);‬
‭temp‬‭.‬‭pop_back‬‭();‬
‭}‬
‭}‬

‭int‬‭main‬‭()‬‭{‬
‭cout‬‭<<‬‭"‭E ‬ nter No. of variables:‬‭";‬
‭int‬‭n‬‭;‬
‭cin‬‭>>‬‭n‬‭;‬
‭vector‬‭<‭p ‬ air‬‭<‬‭int‬‭,‬‭int‬‭>>‬‭scope‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭n‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭E ‬ nter Range:‬‭";‬
‭int‬‭a‬‭,‬‭b‬‭;‬
‭cin‬‭>>‬‭a‬‭>>‬‭b‬‭;‬
‭scope‬‭.‬‭push_back‬‭(‬‭{‬‭a‬‭,‬‭b‬‭}‭)‬ ;‬
‭}‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭cases‬‭(‬‭n‬‭);‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭n‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭-‬‭1‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭first‬‭+‬‭1‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭((‬‭scope‬‭[‭i‬‭]‬ ‬‭.‬‭first‬‭+‬‭scope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭)‬‭/‬‭2‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭-‬‭1‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭);‬
‭cases‬‭[‬‭i‭]‬ ‬‭.‬‭push_back‬‭(‭s‬ cope‬‭[‬‭i‭]‬ ‭.‬‬‭second‬‭+‬‭1‬‭);‬
}‭ ‬
‭vector‬‭<‭i‬nt‬‭>‬‭temp‬‭;‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭result‬‭;‬
‭patterns‬‭(‬‭0‬‭,‬‭temp‬‭,‬‭cases‬‭,‬‭result‬‭);‬
‭cout‬‭<<‬‭"‭S ‬ .No.‬‭"‬‭<<‬‭"‬‭";‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭n‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭V ‬ ariable‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭";‬
‭}‬
‭cout‬‭<<‬‭"‭O ‬ utput‬‭"‬‭<<‬‭endl‬‭;‬
‭int‬‭tc‬‭=‬‭1‬‭;‬
‭for‬‭(‬‭auto‬‭i‬‭:‬‭result‬‭)‬‭{‬
‭cout‬‭<<‬‭setw‬‭(‭5‬ ‬‭)‬‭<<‬‭tc‬‭;‬
‭tc‬‭++;‬
‭int‬‭maxi‬‭=‬‭INT_MIN‬‭;‬
‭bool‬‭flag‬‭=‬‭true‬‭;‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‬‭n‬‭;‬‭j‭+ ‬ +)‬‭{‬
‭if‬‭(‬‭i‭[‬ ‬‭j‭]‬ ‬‭>‬‭scope‬‭[‬‭j‭]‬ ‬‭.‬‭second‬‭||‬‭i‬‭[‭j‬‭]‬ ‬‭<‬‭scope‬‭[‬‭j‭]‬ ‬‭.‬‭first‬‭)‬‭{‬
‭flag‬‭=‬‭false‬‭;‬
‭}‬
‭maxi‬‭=‬‭max‬‭(‬‭maxi‬‭,‬‭i‬‭[‭j‬‭]‬ ‬‭);‬
‭cout‬‭<<‬‭setw‬‭(‭9‬ ‬‭)‬‭<<‬‭i‬‭[‭j‬‭]‬ ‬‭;‬
‭}‬
‭if‬‭(‬‭flag‬‭)‬‭{‬
‭cout‬‭<<‬‭setw‬‭(‭9‬ ‬‭)‬‭<<‬‭maxi‬‭;‬
‭}‬
‭else‬‭{‬
‭cout‬‭<<‬‭"‬‭INVALID‬‭";‬
‭}‬
‭cout‬‭<<‬‭endl‬‭;‬
‭}‬
‭}‬
‭OUTPUT‬‭: -‬
‭EXPERIMENT - 5‬

‭AIM‬‭: -‬‭Write a program to find the type of the triangle‬‭on the basis of sides input by the user‬
‭and generate test cases to test the using‬‭Equivalance‬‭Class Testing.‬

‭Source Code‬‭: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

‭int‬‭num‬‭=‬‭1‬‭;‬

‭void‬‭check‬‭(‬‭int‬‭side1‬‭,‬‭int‬‭side2‬‭,‬‭int‬‭side3‬‭,‬‭int‬‭l‬‭,‬‭int‬‭r‬‭)‬‭{‬
‭cout‬‭<<setw‬‭(‬‭3‬‭)‬‭<<‬‭num‬‭<<‬‭setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭side1‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭side2‬‭<<‬‭setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭side3‬‭<<‬‭"‬‭ ‬‭";‬
‭num‬‭++;‬
‭if‬‭(‬‭side1‬‭<‬‭l‬‭||‬‭side1‬‭>‬‭r‬‭||‬‭side2‬‭<‬‭l‬‭||‬‭side2‬‭>‬‭r‬‭||‬‭side3‬‭<‬‭l‬‭||‬‭side3‬‭>‬‭r‬‭)‬‭cout‬‭<<‬‭"‭I‬ nvalid Input‬‭"‬‭<<‬‭endl‬‭;‬
‭else‬‭if‬‭(‬‭side1‬‭+‬‭side2‬‭<=‬‭side3‬‭||‬‭side1‬‭+‬‭side3‬‭<=‬‭side2‬‭||‬‭side2‬‭+‬‭side3‬‭<=‬‭side1‬‭)‬‭cout‬‭<<‬‭"‭N ‬ ot a‬‭triangle‬‭"‬‭<<‬
‭endl‬‭;‬
‭else‬‭{‬
‭if‬‭(‬‭side1‬‭==‬‭side2‬‭&&‬‭side1‬‭==‬‭side3‬‭)‬‭cout‬‭<<‬‭"‭E ‬ quilateral Triangle‬‭"‬‭<<‬‭endl‬‭;‬
‭else‬‭if‬‭(‬‭side1‬‭==‬‭side2‬‭||‬‭side2‬‭==‬‭side3‬‭||‬‭side1‬‭==‬‭side3‬‭)‬‭cout‬‭<<‬‭"‭I‬ sosceles Triangle‬‭"‬‭<<‬‭endl‬‭;‬
‭else‬‭cout‬‭<<‬‭"‭S
‬ calene Triangle‬‭"‬‭<<‬‭endl‬‭;‬
‭}‬
‭}‬

‭int‬‭main‬‭()‬‭{‬
‭int‬‭left‬‭,‬‭right‬‭;‬

c‭ out‬‭<<‬‭"‭E
‬ nter value range for sides:‬‭";‬
‭cin‬‭>>‬‭left‬‭>>‬‭right‬‭;‬

‭ ap‬‭<‭i‬nt‬‭,‬‭int‬‭>‬‭m‭;‬‬
m
‭m‬‭[‬‭0‬‭]‬‭=‬‭(‬‭left‬‭+‬‭right‬‭)‬‭/‬‭2‬‭;‬
‭m‬‭[‬‭1‬‭]‬‭=‬‭left‬‭-‬‭1‬‭;‬
‭m‬‭[‬‭2‬‭]‬‭=‬‭right‬‭+‬‭1‬‭;‬

c‭ out‬‭<<‬‭"‭< ‬ ----------Input Classes----------->‬‭";‬


‭cout‬‭<<‬‭"‭I‬ 1 = { 1 <= a <= 100, 1 <= b <= 100,‬‭1 <= c <= 100 } (All inputs are valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 2 = { a < 1, 1 <= b <= 100, 1 <= c <=‬‭100 } (a is invalid, b is valid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 3 = { 1 <= a <= 100, b < 1, 1 <= c <=‬‭100 } (a is valid, b is invalid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 4 = { 1 <= a <= 100, 1 <= b <= 100,‬‭c < 1 } (a is valid, b is valid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 5 = { a > 100, 1 <= b <= 100, 1 <= c‬‭<= 100 } (a is invalid, b is valid, c is valid)‬‭\n";‬
c‭ out‬‭<<‬‭"‭I‬ 6 = { 1 <= a <= 100, b > 100, 1 <= c <= 100 } (a is valid, b is invalid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 7 = { 1 <= a <= 100, 1 <= b <= 100,‬‭c > 100 } (a is valid, b is valid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 8 = { a < 1, b < 1, 1 <= c <= 100 }‬‭(a is invalid, b is invalid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 9 = { 1 <= a <= 100, b < 1, c < 1 }‬‭(a is valid, b is invalid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 10 = { a < 1, 1 <= b <= 100, c < 1 }‬‭(a is invalid, b is valid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 11 = { a > 100, b > 100, 1 <= c <= 100‬‭} (a is invalid, b is invalid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 12 = { 1 <= a <= 100, b > 100, c > 100‬‭} (a is valid, b is invalid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 13 = { a > 100, 1 <= b <= 100, c > 100‬‭} (a is invalid, b is valid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 14 = { a < 1, b > 100, 1 <= c <= 100‬‭} (a is invalid, b is invalid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 15 = { a > 100, b < 1, 1 <= c <= 100‬‭} (a is invalid, b is invalid, c is valid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 16 = { 1 <= a <= 100, b < 1, c > 100‬‭} (a is valid, b is invalid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 17 = { 1 <= a <= 100, b > 100, c < 1‬‭} (a is valid, b is invalid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 18 = { a < 1, 1 <= b <= 100, c > 100‬‭} (a is invalid, b is valid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 19 = { a > 100, 1 <= b <= 100, c < 1‬‭} (a is invalid, b is valid, c is invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 20 = { a < 1, b < 1, c < 1 } (All inputs‬‭are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 21 = { a > 100, b > 100, c > 100 } (All‬‭inputs are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 22 = { a < 1, b < 1, c > 100 } (All inputs‬‭are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 23 = { a < 1, b > 100, c < 1 } (All inputs‬‭are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 24 = { a > 100, b < 1, c < 1 } (All inputs‬‭are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 25 = { a > 100, b > 100, c < 1 } (All‬‭inputs are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 26 = { a > 100, b < 1, c > 100 } (All‬‭inputs are invalid)‬‭\n";‬
‭cout‬‭<<‬‭"‭I‬ 27 = { a < 1, b > 100, c > 100 } (All‬‭inputs are invalid)‬‭\n";‬

c‭ out‬‭<<‬‭endl<<‬‭"‬‭<---------Equivalence Input Class----------------->‬‭"‬‭<<‬‭endl‬‭;‬


‭cout‬‭<<‬‭"‭C ‬ aseID Side1 Side2 Side3‬‭ Output‬‭"‬‭<<‬‭endl‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭3‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‬‭3‬‭;‬‭j‭+ ‬ +)‬‭{‬
‭for‬‭(‬‭int‬‭k‬‭=‬‭0‬‭;‬‭k‬‭<‬‭3‬‭;‬‭k‬‭++)‬‭{‬
‭check‬‭(‬‭m‭[‬ ‬‭i‭]‬ ‭,‬‬‭m‬‭[‭j‬‭]‬ ‬‭,‬‭m‭[‬ ‬‭k‬‭]‭,‬‬‭left‬‭,‬‭right‬‭);‬
‭}‬
‭}‬
‭}‬

c‭ out‬‭<<‬‭endl‬‭<<‬‭"‭< ‬ ---------Equivalence Output Class----------------->‬‭"‬‭<<‬‭endl‬‭;‬


‭cout‬‭<<‬‭"‭C ‬ aseID Side1 Side2 Side3‬‭ Output‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭setw‬‭(‬‭5‬‭)‬‭<<‬‭"‭O ‬ 1‬‭"‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭50‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭50‬‭<<‬‭setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭50‬‭<<‬‭"‬‭ ‬‭"‬‭<<‬‭"‭E‬ quilateral‬
‭Triangle‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭setw‬‭(‬‭5‬‭)‬‭<<‬‭"‭O ‬ 2‬‭"‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭50‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭40‬‭<<‬‭setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭50‬‭<<‬‭"‬‭ ‬‭"‬‭<<‬‭"‭S‬ calene‬
‭Triangle‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭setw‬‭(‬‭5‬‭)‬‭<<‬‭"‭O‬ 3‬‭"‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭30‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭40‬‭<<‬‭setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭50‬‭<<‬‭"‬‭ ‬‭"‬‭<<‬‭"‭I‬ sosceles‬
‭Triangle‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭setw‬‭(‬‭5‬‭)‬‭<<‬‭"‭O
‬ 4‬‭"‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭100‬‭<<‬‭setw‬‭(‬‭10‬‭)‬‭<<‬‭50‬‭<<‬‭setw‬‭(‭1‬ 0‬‭)‬‭<<‬‭50‬‭<<‬‭"‬‭ ‬‭"‬‭<<‬‭"‭N ‬ ot a‬
‭Triangle‬‭"‬‭<<‬‭endl‬‭;‬

‭return‬‭0‬‭;}‬
‭Output‬‭: -‬
‭EXPERIMENT - 6‬

‭Aim: -‬‭Write a program to find the type of the triangle‬‭on the basis of sides input by the user‬
‭and generate test cases to test the program using‬‭Decision Table Testing.‬

‭Source Code: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭iostream‬‭>‬
‭#‬‭include‬‭<‬‭vector‬‭>‬

‭using‬‭namespace‬‭std‬‭;‬

v‭ ector‬‭<‭v‬ ector‬‭<‭i‬nt‬‭>>‬‭sides‬‭(‭7‬ ‬‭,‬‭vector‬‭<‭i‬nt‬‭>(‬‭3‬‭,‬‭0‬‭));‬


‭int‬‭a‬‭,‬‭b‬‭,‬‭c‭;‬‬

‭string‬‭result‬‭(‬‭int‬‭a‭,‬‬‭int‬‭b‬‭,‬‭int‬‭c‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭arr‬‭)‬‭{‬
‭string‬‭result‬‭=‬‭"‭N ‬ ot a Triangle‬‭";‬
‭if‬‭(‬‭a‬‭<‬‭arr‬‭[‬‭0‬‭][‬‭0‬‭]‬‭||‬‭a‬‭>‬‭arr‬‭[‭0‬ ‬‭][‬‭1‬‭]‬‭||‬‭b‬‭<‬‭arr‬‭[‭1‬ ‬‭][‬‭0‬‭]‬‭||‬‭b‬‭>‬‭arr‬‭[‭1‬ ‬‭][‬‭1‬‭]‬‭||‬‭c‬‭<‬‭arr‬‭[‬‭2‬‭][‬‭0‬‭]‬‭||‬‭c‬‭>‬‭arr‬‭[‬‭2‬‭][‬‭1‬‭]‭)‬ ‬‭{‬
‭result‬‭=‬‭"‭I‬ nput values are out of range‬‭";‬
‭}‬‭else‬‭if‬‭(‬‭a‬‭<‬‭b‬‭+‬‭c‬‭&&‬‭b‬‭<‬‭a‬‭+‬‭c‬‭&&‬‭c‬‭<‬‭a‬‭+‬‭b‬‭)‬‭{‬
‭if‬‭(‬‭a‬‭==‬‭b‬‭&&‬‭b‬‭==‬‭c‭)‬ ‬‭{‬
‭result‬‭=‬‭"‭E ‬ quilateral Triangle‬‭";‬
‭}‬‭else‬‭if‬‭(‬‭a‬‭==‬‭b‬‭||‬‭b‬‭==‬‭c‬‭||‬‭a‬‭==‬‭c‬‭)‬‭{‬
‭result‬‭=‬‭"‭I‬ sosceles Triangle‬‭";‬
‭}‬‭else‬‭{‬
‭result‬‭=‬‭"‭S
‬ calene Triangle‬‭";‬
‭}‬
‭}‬
‭return‬‭result‬‭;‬
‭}‬

‭string‬‭Build_DT‬‭()‬‭{‬
‭string‬‭str‬‭=‬‭"\n‬‭DECISION TABLE FOR TRIANGLE CLASSIFICATION‬‭PROBLEM‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭-‬ ---------------------------------------------------------------‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭D ‬ ecisions | 1 | 2 | 3 |‬‭4 | 5 | 6 | 7 | 8 | 9 | 10| 11|‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭-‬ ---------------------------------------------------------------‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭C ‬ 1: a < b + c? | F | T | T |‬‭T | T | T | T | T | T | T | T |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭C ‬ 2: b < a + c? | - | F | T |‬‭T | T | T | T | T | T | T | T |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭C ‬ 3: c < a + b? | - | - | F |‬‭T | T | T | T | T | T | T | T |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭C ‬ 4: a = b ? | - | - | - |‬‭T | T | T | T | F | F | F | F |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭C‬ 5: a = c ? | - | - | - |‬‭T | T | F | F | T | F | F | F |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭C
‬ 6: b = c ? | - | - | - |‬‭T | F | T | F | F | F | T | F |‬‭\n";‬
s‭ tr‬‭=‬‭str‬‭+‬‭"‭-‬ ---------------------------------------------------------------‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭R ‬ ule count |32 |16 | 8 |‬‭1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭-‬ ---------------------------------------------------------------‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭A ‬ 1: Not a triangle | X | X | X |‬‭ | | | | | | | |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭A ‬ 2: Scalene | | | |‬‭ | | | | | | | X |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭A ‬ 3: Isosceles | | | |‬‭ | | | X | | X | X | |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭A‬ 4: Equilateral | | | |‬‭X | | | | | | | |‬‭\n";‬
‭str‬‭=‬‭str‬‭+‬‭"‭A
‬ 5: Impossible | | | |‬‭ | X | X | | X | | | |‬‭\n";‬
‭return‬‭str‬‭;‬
‭}‬

‭int‬‭not_triangle‬‭(‬‭int‬‭ind‬‭,‬‭vector‬‭<‭v‬ ector‬‭<‭i‬nt‬‭>>‬‭arr‬‭)‬‭{‬
‭a‬‭=‬‭arr‬‭[‬‭0‬‭][‬‭1‬‭]‬‭;‬
‭b‬‭=‬‭arr‬‭[‬‭1‬‭][‬‭2‬‭]‬‭;‬
‭c‬‭=‬‭arr‬‭[‬‭2‬‭][‬‭2‬‭]‬‭;‬
‭while‬‭(‬‭a‬‭<‬‭(‬‭b‬‭+‬‭c‬‭))‬‭{‬
‭b‬‭=‬‭b‬‭/‬‭2‬‭;‬
‭c‬‭=‬‭c‬‭/‬‭2‬‭;‬
‭}‬
‭sides‬‭[‬‭0‬‭][‬‭0‬‭]‬‭=‬‭a‭;‬‬
‭sides‬‭[‬‭0‬‭][‬‭1‬‭]‬‭=‬‭b‬‭;‬
‭sides‬‭[‬‭0‬‭][‬‭2‬‭]‬‭=‬‭c‭;‬‬
‭ind‬‭++;‬
‭a‬‭=‬‭arr‬‭[‬‭0‬‭][‬‭2‬‭]‬‭;‬
‭b‬‭=‬‭arr‬‭[‬‭1‬‭][‬‭1‬‭]‬‭;‬
‭c‬‭=‬‭arr‬‭[‬‭2‬‭][‬‭2‬‭]‬‭;‬
‭while‬‭(‬‭b‬‭<‬‭(‬‭a‬‭+‬‭c‬‭))‬‭{‬
‭a‬‭=‬‭a‬‭/‬‭2‬‭;‬
‭c‬‭=‬‭c‬‭/‬‭2‬‭;‬
‭}‬
‭sides‬‭[‬‭1‬‭][‬‭0‬‭]‬‭=‬‭a‭;‬‬
‭sides‬‭[‬‭1‬‭][‬‭1‬‭]‬‭=‬‭b‬‭;‬
‭sides‬‭[‬‭1‬‭][‬‭2‬‭]‬‭=‬‭c‭;‬‬
‭ind‬‭++;‬
‭a‬‭=‬‭arr‬‭[‬‭0‬‭][‬‭2‬‭]‬‭;‬
‭b‬‭=‬‭arr‬‭[‬‭1‬‭][‬‭2‬‭]‬‭;‬
‭c‬‭=‬‭arr‬‭[‬‭2‬‭][‬‭1‬‭]‬‭;‬
‭while‬‭(‬‭c‬‭<‬‭(‬‭a‬‭+‬‭b‬‭))‬‭{‬
‭a‬‭=‬‭a‬‭/‬‭2‬‭;‬
‭b‬‭=‬‭b‬‭/‬‭2‬‭;‬
‭}‬
‭sides‬‭[‬‭2‬‭][‬‭0‬‭]‬‭=‬‭a‭;‬‬
‭sides‬‭[‬‭2‬‭][‬‭1‬‭]‬‭=‬‭b‬‭;‬
‭sides‬‭[‬‭2‬‭][‬‭2‬‭]‬‭=‬‭c‭;‬‬
‭ind‬‭++;‬
‭return‬‭ind‬‭;‬
‭}‬

‭int‬‭Equilateral‬‭(‬‭int‬‭ind‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭arr‬‭)‬‭{‬
‭a‬‭=‬‭arr‬‭[‬‭0‬‭][‬‭3‬‭]‬‭;‬
‭b‬‭=‬‭arr‬‭[‬‭1‬‭][‬‭3‬‭]‬‭;‬
‭c‬‭=‬‭arr‬‭[‬‭2‬‭][‬‭3‬‭]‬‭;‬
‭int‬‭min_max‬‭=‬‭arr‬‭[‭0‬ ‬‭][‬‭0‬‭]‬‭,‬‭max_min‬‭=‬‭arr‬‭[‭0‬ ‬‭][‬‭1‬‭]‬‭,‬‭nominal_val‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭3‬‭;‬‭i‭+
‬ +)‬‭{‬
‭if‬‭(‬‭min_max‬‭>‬‭arr‬‭[‬‭i‭]‬ [‬‭0‬‭]‬‭)‬
‭min_max‬‭=‬‭arr‬‭[‬‭i‭]‬ [‬‭0‬‭]‭;‬‬
‭if‬‭(‬‭max_min‬‭>‬‭arr‬‭[‬‭i‭]‬ [‬‭1‬‭]‬‭)‬
‭max_min‬‭=‬‭arr‬‭[‬‭i‭]‬ [‬‭1‬‭]‭;‬‬
‭}‬
‭nominal_val‬‭=‬‭(‬‭min_max‬‭+‬‭max_min‬‭)‬‭/‬‭2‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭0‬‭]‬‭=‬‭nominal_val‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭1‬‭]‬‭=‬‭nominal_val‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭2‬‭]‬‭=‬‭nominal_val‬‭;‬
‭ind‬‭++;‬
‭return‬‭ind‬‭;‬
‭}‬

‭int‬‭Isosceles‬‭(‬‭int‬‭ind‬‭,‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭arr‬‭)‬‭{‬
‭a‬‭=‬‭arr‬‭[‬‭0‬‭][‬‭3‬‭]‬‭;‬
‭b‬‭=‬‭arr‬‭[‬‭1‬‭][‬‭3‬‭]‬‭;‬
‭c‬‭=‬‭arr‬‭[‬‭2‬‭][‬‭3‬‭]‬‭;‬
‭int‬‭min_max‬‭=‬‭arr‬‭[‭0‬ ‬‭][‬‭0‬‭]‬‭,‬‭max_min‬‭=‬‭arr‬‭[‭0‬ ‬‭][‬‭1‬‭]‬‭,‬‭nominal_val‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭3‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭if‬‭(‬‭min_max‬‭>‬‭arr‬‭[‬‭i‭]‬ [‬‭0‬‭]‬‭)‬
‭min_max‬‭=‬‭arr‬‭[‬‭i‭]‬ [‬‭0‬‭]‭;‬‬
‭if‬‭(‬‭max_min‬‭>‬‭arr‬‭[‬‭i‭]‬ [‬‭1‬‭]‬‭)‬
‭max_min‬‭=‬‭arr‬‭[‬‭i‭]‬ [‬‭1‬‭]‭;‬‬
‭}‬
‭nominal_val‬‭=‬‭(‬‭min_max‬‭+‬‭max_min‬‭)‬‭/‬‭2‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭0‬‭]‬‭=‬‭arr‬‭[‬‭0‬‭][‬‭0‬‭]‭;‬‬
‭sides‬‭[‬‭ind‬‭][‬‭1‬‭]‬‭=‬‭nominal_val‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭2‬‭]‬‭=‬‭nominal_val‬‭;‬
‭ind‬‭++;‬
‭sides‬‭[‬‭ind‬‭][‬‭0‬‭]‬‭=‬‭nominal_val‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭1‬‭]‬‭=‬‭arr‬‭[‬‭1‬‭][‬‭0‬‭]‭;‬‬
‭sides‬‭[‬‭ind‬‭][‬‭2‬‭]‬‭=‬‭nominal_val‬‭;‬
‭ind‬‭++;‬
‭sides‬‭[‬‭ind‬‭][‬‭0‬‭]‬‭=‬‭nominal_val‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭1‬‭]‬‭=‬‭nominal_val‬‭;‬
‭sides‬‭[‬‭ind‬‭][‬‭2‬‭]‬‭=‬‭arr‬‭[‬‭2‬‭][‬‭0‬‭]‭;‬‬
i‭nd‬‭++;‬
‭return‬‭ind‬‭;‬
‭}‬

‭int‬‭impossible‬‭(‬‭int‬‭ind‬‭)‬‭{‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭3‬‭;‬‭i‭+
‬ +)‬‭{‬
‭cout‬‭<<‬‭ind‬‭+‬‭i‬‭<<‬‭"\t‬‭?‬‭\t‬‭?‭\‬t‬‭?‭\‬t‬‭Impossible‬‭"‬‭<<‬‭endl‬‭;‬
‭}‬
‭ind‬‭=‬‭ind‬‭+‬‭3‬‭;‬
‭return‬‭ind‬‭;‬
‭}‬

‭int‬‭main‬‭()‬‭{‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭arr‬‭(‭3‬ ‭,‬‬‭vector‬‭<‬‭int‬‭>(‬‭3‬‭,‬‭0‬‭));‬
‭cout‬‭<<‬‭"‭E ‬ nter the sides of the Triangle:‬‭"‬‭<<‬‭endl‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭3‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭E ‬ nter min and max values of side‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‭:‬‬‭";‬
‭cin‬‭>>‬‭arr‬‭[‬‭i‭]‬ [‬‭0‬‭]‬‭>>‬‭arr‬‭[‬‭i‭]‬ [‬‭1‬‭]‬‭;‬
‭arr‬‭[‬‭i‭]‬ [‬‭2‬‭]‬‭=‬‭(‬‭arr‬‭[‬‭i‭]‬ [‬‭0‬‭]‬‭+‬‭arr‬‭[‬‭i‭]‬ [‬‭1‬‭]‬‭)‬‭/‬‭2‬‭;‬
‭arr‬‭[‬‭i‭]‬ [‬‭3‬‭]‬‭=‬‭arr‬‭[‭i‬‭]‬ [‬‭1‬‭]‬‭-‬‭arr‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭;‬
‭}‬
‭cout‬‭<<‬‭Build_DT‬‭()‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"‭D ‬ ECISION TABLE - TEST CASES‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"‭S ‬ .No‬‭\t‬‭a‭\‬t‬‭b‬‭\t‬‭c‬‭\t‬‭Expected Output‬‭"‬‭<<‬‭endl‬‭;‬
‭int‬‭ind‬‭=‬‭0‬‭;‬
‭ind‬‭=‬‭not_triangle‬‭(‭i‬nd‬‭,‬‭arr‬‭);‬
‭ind‬‭=‬‭Equilateral‬‭(‭i‬nd‬‭,‬‭arr‬‭);‬
‭ind‬‭=‬‭Isosceles‬‭(‬‭ind‬‭,‬‭arr‬‭);‬
‭ind‬‭=‬‭1‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭7‬‭;‬‭i‭+ ‬ +)‬‭{‬
‭a‬‭=‬‭sides‬‭[‬‭i‬‭][‬‭0‬‭]‭;‬‬
‭b‬‭=‬‭sides‬‭[‬‭i‭]‬ [‬‭1‬‭]‭;‬‬
‭c‬‭=‬‭sides‬‭[‬‭i‬‭][‬‭2‬‭]‭;‬‬
‭cout‬‭<<‬‭ind‬‭<<‬‭"\t"‬‭<<‬‭a‬‭<<‬‭"\t"‬‭<<‬‭b‬‭<<‬‭"\t"‬‭<<‬‭c‬‭<<‬‭"\t"‬‭<<‬‭result‬‭(‭a‬ ‬‭,‬‭b‬‭,‬‭c‭,‬‬‭arr‬‭)‬‭<<‬‭endl‬‭;‬
‭ind‬‭++;‬
‭}‬
‭ind‬‭=‬‭impossible‬‭(‭i‬nd‬‭);‬
‭cout‬‭<<‬‭ind‬‭<<‬‭"\t"‬‭<<‬‭arr‬‭[‬‭0‬‭][‬‭1‬‭]‬‭-‬‭1‬‭<<‬‭"\t"‬‭<<‬‭arr‬‭[‬‭1‬‭][‬‭2‬‭]‬‭<<‬‭"\t"‬‭<<‬‭arr‬‭[‬‭2‬‭][‬‭2‬‭]‬‭+‬‭2‬‭<<‬‭"\t"‬‭<<‬‭result‬‭(‬‭arr‬‭[‬‭0‬‭][‬‭1‬‭]‬‭-‬
‭1‬‭,‬‭arr‬‭[‬‭1‬‭][‬‭2‬‭]‬‭,‬‭arr‬‭[‭2‬ ‬‭][‬‭2‬‭]‬‭+‬‭2‬‭,‬‭arr‬‭)‬‭<<‬‭endl‬‭;‬
‭return‬‭0‭;‬‬
‭}‬
‭Output: -‬
‭EXPERIMENT - 7‬

‭Aim: -‬‭Write a program to find Cyclomatic complexity‬‭of a program‬‭.‬

‭Source Code: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

c‭ lass‬‭CyclomaticComplexityCalculator‬‭{‬
‭public‬‭:‬
‭int‬‭calculate‬‭(‬‭const‬‭vector‬‭<‭s‬ tring‬‭>‬‭&‬‭sourceCode‬‭)‬‭{‬
‭int‬‭nodes‬‭=‬‭0‬‭;‬

‭for‬‭(‬‭const‬‭string‬‭&‬‭line‬‭:‬‭sourceCode‬‭)‬‭{‬
‭nodes‬‭+=‬‭countDecisiveNodes‬‭(‭l‬ine‬‭);‬
‭}‬
‭int‬‭complexity‬‭=‬‭nodes‬‭+‬‭1‬‭;‬
‭return‬‭complexity‬‭;‬
}‭ ‬
‭private‬‭:‬
‭int‬‭countDecisiveNodes‬‭(‬‭const‬‭string‬‭&‬‭line‬‭)‬‭{‬
‭int‬‭controlFlows‬‭=‬‭1‬‭;‬
‭if‬‭(‬‭line‬‭.‬‭find‬‭("‬‭if‬‭")‬‭!=‬‭string‬‭::‬‭npos‬‭||‬‭line‬‭.‬‭find‬‭("‬‭else‬‭if‬‭")‬‭!=‬‭string‬‭::‬‭npos‬‭)‬
‭controlFlows‬‭++;‬
‭if‬‭(‬‭line‬‭.‬‭find‬‭("‬‭for‬‭")‬‭!=‬‭string‬‭::‬‭npos‬‭||‬‭line‬‭.‬‭find‬‭("‬‭while‬‭")‬‭!=‬‭string‬‭::‬‭npos‬‭)‬
‭controlFlows‬‭++;‬
‭if‬‭(‬‭line‬‭.‬‭find‬‭("‬‭case‬‭")‬‭!=‬‭string‬‭::‬‭npos‬‭)‬
‭controlFlows‬‭++;‬
‭return‬‭controlFlows‬‭;‬
‭}‬
‭};‬

‭int‬‭main‬‭()‬‭{‬
‭ifstream‬‭inputFile‬‭("‬‭source_code.txt‬‭");‬
‭if‬‭(!‬‭inputFile‬‭.‬‭is_open‬‭())‬‭{‬
‭cerr‬‭<<‬‭"‭F ‬ ailed to open the source_code.txt‬‭file.‬‭"‬‭<<‬‭endl‬‭;‬
‭return‬‭1‬‭;‬
‭}‬
‭vector‬‭<‭s‬ tring‬‭>‬‭sourceCode‬‭;‬
‭string‬‭line‬‭;‬
‭while‬‭(‬‭getline‬‭(‬‭inputFile‬‭,‬‭line‬‭))‬‭{‬
‭sourceCode‬‭.‬‭push_back‬‭(‬‭line‬‭);‬
}‭ ‬
‭inputFile‬‭.‬‭close‬‭();‬
‭for‬‭(‬‭auto‬‭i‭:‬‬‭sourceCode‬‭){‬
‭cout‬‭<<‬‭i‭< ‬ <endl‬‭;‬
‭}‬

‭ yclomaticComplexityCalculator‬‭calculator‬‭;‬
C
‭int‬‭complexity‬‭=‬‭calculator‬‭.‬‭calculate‬‭(‭s‬ ourceCode‬‭);‬
‭cout‬‭<<‬‭"‭C ‬ yclomatic Complexity:‬‭"‬‭<<‬‭complexity‬‭<<‬‭endl‬‭;‬
‭return‬‭0‬‭;‬
‭}‬

‭Output: -‬
‭EXPERIMENT - 8‬

‭Aim: -‬‭Write a program to input graph matrix and perform‬‭DD path testing.‬

‭Source Code: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭bits/stdc++.h‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

c‭ lass‬‭Edge‬‭{‬
‭public‬‭:‬
‭int‬‭wt‬‭;‬
‭int‬‭v‬‭;‬
‭Edge‬‭(‬‭int‬‭nb‬‭,‬‭int‬‭w‬‭)‬‭{‬
‭v‬‭=‬‭nb‬‭;‬
‭wt‬‭=‬‭w‬‭;‬
‭}‬
‭};‬

v‭ oid‬‭dfs_printPaths‬‭(‭v‬ ector‬‭<‬‭vector‬‭<‬‭Edge‬‭*>>‬‭&‭g‬ raph‬‭,‬‭int‬‭src‬‭,‬‭vector‬‭<‬‭bool‬‭>‬‭&‭v‬ is‬‭,‬‭int‬


‭endNode‬‭,‬‭int‬‭&‭c‬ ount‬‭,‬‭string‬‭path‬‭)‬‭{‬
‭if‬‭(‬‭src‬‭==‬‭endNode‬‭)‬‭{‬
‭path‬‭+=‬‭"‭N ‬ ‬‭"‬‭+‬‭to_string‬‭(‬‭endNode‬‭);‬
‭cout‬‭<<‬‭"‭P ‬ ath‬‭"‬‭<<‬‭count‬‭++‬‭<<‬‭"‭:‬‬‭"‬‭<<‬‭path‬‭<<‬‭endl‬‭;‬
‭return‬‭;‬
‭}‬
‭vis‬‭[‬‭src‬‭]‬‭=‬‭true‬‭;‬
‭for‬‭(‬‭Edge‬‭*‬‭e‬‭:‬‭graph‬‭[‬‭src‬‭]‭)‬ ‬‭{‬
‭if‬‭(‬‭vis‬‭[‭e‬ ‬‭->‬‭v‬‭]‬‭==‬‭false‬‭)‬
‭dfs_printPaths‬‭(‬‭graph‬‭,‬‭e‭-‬ >‬‭v‬‭,‬‭vis‬‭,‬‭endNode‬‭,‬‭count‬‭,‬‭path‬‭+‬‭"‭N
‬ ‭"‬ ‬‭+‬‭to_string‬‭(‭s‬ rc‬‭)‬‭+‬‭"‬‭->‬‭");‬
‭}‬
‭vis‬‭[‬‭src‬‭]‬‭=‬‭false‬‭;‬
‭}‬

‭int‬‭main‬‭()‬‭{‬
‭int‬‭n‬‭;‬‭ ‬
‭cout‬‭<<‬‭"‭E ‬ nter the number of Decision nodes (Size‬‭of Matrix):‬‭";‬
‭cin‬‭>>‬‭n‬‭;‬
‭cout‬‭<<‬‭"‭P ‬ lease input the graph matrix:‬‭\n";‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭mat‬‭(‬‭n‬‭,‬‭vector‬‭<‬‭int‬‭>(‬‭n‬‭,‬‭0‬‭));‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭n‬‭;‬‭i‭+
‬ +)‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‬‭n‬‭;‬‭j‭+
‬ +)‬
c‭ in‬‭>>‬‭mat‬‭[‭i‬‬‭][‬‭j‭]‬ ‭;‬‬
‭vector‬‭<‭v‬ ector‬‭<‬‭Edge‬‭*>>‬‭graph‬‭(‭n‬ ‬‭,‬‭vector‬‭<‭E ‬ dge‬‭*>());‬
‭int‬‭P‬‭=‬‭1‬‭;‬
‭int‬‭e‬‭=‬‭0‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭n‬‭;‬‭i‭+ ‬ +)‬
‭for‬‭(‬‭int‬‭j‬‭=‬‭0‬‭;‬‭j‬‭<‬‭n‬‭;‬‭j‭+ ‬ +)‬
‭if‬‭(‬‭mat‬‭[‬‭i‭]‬ [‬‭j‭]‬ ‬‭==‬‭1‬‭)‬‭{‬
‭graph‬‭[‭i‬‬‭]‭.‬‬‭push_back‬‭(new‬‭Edge‬‭(‬‭j‭,‬‬‭1‬‭));‬
‭e‬‭++;‬
‭}‬
‭vector‬‭<‭b‬ ool‬‭>‬‭vis‬‭(‭n‬ ‬‭,‬‭false‬‭);‬
‭int‬‭count‬‭=‬‭1‬‭;‬
‭cout‬‭<<‬‭"‭C ‬ yclomatic Complexity is:‬‭"‬‭<<‬‭e‬‭-‬‭n‬‭+‬‭2‬‭*‬‭P‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"\n‬‭Paths are:‬‭\n";‬
‭dfs_printPaths‬‭(‬‭graph‬‭,‬‭0‬‭,‬‭vis‬‭,‬‭n‬‭-‬‭1‬‭,‬‭count‬‭,‬‭"");‬
‭cout‬‭<<‬‭endl‬‭;‬
‭return‬‭0‬‭;‬
‭}‬

‭Output: -‬
‭EXPERIMENT - 9‬

‭AIM‬‭: -‬‭Write a program to perform mutation testing.‬

‭Source Code‬‭: -‬
/‭/ Author : Aman Gupta‬
‭// Roll Number : 2K21/SE/21‬
‭// Batch : SE A1(G1)‬
‭#‬‭include‬‭<‬‭iostream‬‭>‬
‭#‬‭include‬‭<‬‭vector‬‭>‬
‭using‬‭namespace‬‭std‬‭;‬

‭int‬‭killed‬‭=‬‭0‬‭;‬

‭int‬‭correct‬‭(‬‭vector‬‭<‬‭int‬‭>‬‭testCase‬‭)‬‭{‬
‭int‬‭A‬‭=‬‭testCase‬‭[‬‭0‬‭]‭;‬‬
‭int‬‭B‬‭=‬‭testCase‬‭[‬‭1‬‭]‭;‬‬
‭int‬‭C‬‭=‬‭testCase‬‭[‬‭2‬‭]‭;‬‬

‭if‬‭(‬‭A‬‭>‬‭B‭)‬ ‬
‭if‬‭(‬‭A‬‭>‬‭C‭)‬ ‬
‭return‬‭A‭;‬‬
‭else‬
‭return‬‭C‭;‬‬
‭else‬
‭if‬‭(‬‭C‬‭>‬‭B‭)‬ ‬
‭return‬‭C‭;‬‬
‭else‬
‭return‬‭B‭;‬‬

‭return‬‭0‬‭;‬
‭}‬

‭int‬‭M1_Code‬‭(‭v‬ ector‬‭<‬‭int‬‭>‬‭testCase‬‭)‬‭{‬
‭int‬‭A‬‭=‬‭testCase‬‭[‬‭0‬‭]‭;‬‬
‭int‬‭B‬‭=‬‭testCase‬‭[‬‭1‬‭]‭;‬‬
‭int‬‭C‬‭=‬‭testCase‬‭[‬‭2‬‭]‭;‬‬

‭if‬‭(‬‭A‬‭<‬‭B‭)‬ ‬
‭if‬‭(‬‭A‬‭>‬‭C‭)‬ ‬
‭return‬‭A‭;‬‬
‭else‬
‭return‬‭C‭;‬‬
‭else‬
‭if‬‭(‬‭C‬‭>‬‭B‭)‬ ‬
‭return‬‭C‭;‬‬
‭else‬
‭return‬‭B‭;‬‬

‭return‬‭0‬‭;‬
‭}‬

‭int‬‭M2_Code‬‭(‭v‬ ector‬‭<‬‭int‬‭>‬‭testCase‬‭)‬‭{‬
‭int‬‭A‬‭=‬‭testCase‬‭[‬‭0‬‭]‭;‬‬
‭int‬‭B‬‭=‬‭testCase‬‭[‬‭1‬‭]‭;‬‬
‭int‬‭C‬‭=‬‭testCase‬‭[‬‭2‬‭]‭;‬‬

‭if‬‭(‬‭A‬‭>‬‭(‬‭B‬‭+‬‭C‭)‬ )‬
‭if‬‭(‬‭A‬‭>‬‭C‭)‬ ‬
‭return‬‭A‭;‬‬
‭else‬
‭return‬‭C‭;‬‬
‭else‬
‭if‬‭(‬‭C‬‭>‬‭B‭)‬ ‬
‭return‬‭C‭;‬‬
‭else‬
‭return‬‭B‭;‬‬

‭return‬‭0‬‭;‬
‭}‬

‭int‬‭M3_Code‬‭(‭v‬ ector‬‭<‬‭int‬‭>‬‭testCase‬‭)‬‭{‬
‭int‬‭A‬‭=‬‭testCase‬‭[‬‭0‬‭]‭;‬‬
‭int‬‭B‬‭=‬‭testCase‬‭[‬‭1‬‭]‭;‬‬
‭int‬‭C‬‭=‬‭testCase‬‭[‬‭2‬‭]‭;‬‬

‭if‬‭(‬‭A‬‭>‬‭B‭)‬ ‬
‭if‬‭(‬‭A‬‭<‬‭C‭)‬ ‬
‭return‬‭A‭;‬‬
‭else‬
‭return‬‭C‭;‬‬
‭else‬
‭if‬‭(‬‭C‬‭>‬‭B‭)‬ ‬
‭return‬‭C‭;‬‬
‭else‬
‭return‬‭B‭;‬‬

‭return‬‭0‬‭;‬
‭}‬
‭int‬‭M4_Code‬‭(‭v‬ ector‬‭<‬‭int‬‭>‬‭testCase‬‭)‬‭{‬
‭int‬‭A‬‭=‬‭testCase‬‭[‬‭0‬‭]‭;‬‬
‭int‬‭B‬‭=‬‭testCase‬‭[‬‭1‬‭]‭;‬‬
‭int‬‭C‬‭=‬‭testCase‬‭[‬‭2‬‭]‭;‬‬

‭if‬‭(‬‭A‬‭>‬‭B‭)‬ ‬
‭if‬‭(‬‭A‬‭>‬‭C‭)‬ ‬
‭return‬‭A‭;‬‬
‭else‬
‭return‬‭C‭;‬‬
‭else‬
‭if‬‭(‬‭C‬‭==‬‭B‬‭)‬
‭return‬‭C‭;‬‬
‭else‬
‭return‬‭B‭;‬‬

‭return‬‭0‬‭;‬
‭}‬

‭int‬‭M5_Code‬‭(‭v‬ ector‬‭<‬‭int‬‭>‬‭testCase‬‭)‬‭{‬
‭int‬‭A‬‭=‬‭testCase‬‭[‬‭0‬‭]‭;‬‬
‭int‬‭B‬‭=‬‭testCase‬‭[‬‭1‬‭]‭;‬‬
‭int‬‭C‬‭=‬‭testCase‬‭[‬‭2‬‭]‭;‬‬

‭if‬‭(‬‭A‬‭>‬‭B‭)‬ ‬
‭if‬‭(‬‭A‬‭>‬‭C‭)‬ ‬
‭return‬‭A‭;‬‬
‭else‬
‭return‬‭C‭;‬‬
‭else‬
‭if‬‭(‬‭C‬‭>‬‭B‭)‬ ‬
‭return‬‭B‭;‬‬
‭else‬
‭return‬‭B‭;‬‬

‭return‬‭0‬‭;‬
‭}‬

‭void‬‭M1‬‭(‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭testCases‬‭)‬‭{‬
‭cout‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ---------------------------------------------------‬‭---- ‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ Mutant 1‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"\t\t‬‭ A‬‭\t‬‭B‬‭\t‬‭C‬‭\t‬‭Expected‬‭\t‬‭ Actual‬‭"‬‭<<‬‭endl‬‭;‬
b‭ ool‬‭flag‬‭=‬‭false‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭testCases‬‭.‬‭size‬‭();‬‭i‭+
‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭T ‬ est Case‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭‬‭\t‬‭‬‭‬‭"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭<<‬‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‬‭][‬‭1‬‭]‬‭<<‬
‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭2‬‭]‬‭<<‬‭"\t‬‭"‬‭<<‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭<<‬‭"\t\t"‬‭<<‬‭M1_Code‬‭(‭t‬estCases‬‭[‭i‬‭]‬ ‬‭)‬‭<<‬
‭endl‬‭;‬
‭if‬‭(‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭!=‬‭M1_Code‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭&&‬‭flag‬‭==‬‭false‬‭)‬‭{‬
‭killed‬‭++;‬
‭flag‬‭=‬‭true‬‭;‬
‭}‬
‭}‬

‭if‬‭(‬‭flag‬‭==‬‭true‬‭)‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M‬ utant Killed‬‭";‬
‭else‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M
‬ utant not Killed‬‭";‬
‭}‬

‭void‬‭M2‬‭(‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭testCases‬‭)‬‭{‬
‭cout‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ----------------------------------------------------‬‭‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ Mutant 2‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"\t\t‬‭ A‬‭\t‬‭B‬‭\t‬‭C‬‭\t‬‭Expected‬‭\t‬‭ Actual‬‭"‬‭<<‬‭endl‬‭;‬

b‭ ool‬‭flag‬‭=‬‭false‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭testCases‬‭.‬‭size‬‭();‬‭i‭+
‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭T ‬ est Case‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭‬‭\t‬‭‬‭‬‭"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭<<‬‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‬‭][‬‭1‬‭]‬‭<<‬
‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭2‬‭]‬‭<<‬‭"\t‬‭"‬‭<<‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭<<‬‭"\t\t"‬‭<<‬‭M2_Code‬‭(‭t‬estCases‬‭[‭i‬‭]‬ ‬‭)‬‭<<‬
‭endl‬‭;‬
‭if‬‭(‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭!=‬‭M2_Code‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭&&‬‭flag‬‭==‬‭false‬‭)‬‭{‬
‭killed‬‭++;‬
‭flag‬‭=‬‭true‬‭;‬
‭}‬
‭}‬

‭if‬‭(‬‭flag‬‭==‬‭true‬‭)‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M‬ utant Killed‬‭";‬
‭else‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M
‬ utant not Killed‬‭";‬
‭}‬

‭void‬‭M3‬‭(‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭testCases‬‭)‬‭{‬
‭cout‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ----------------------------------------------------‬‭‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ Mutant 3‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"\t\t‬‭ A‬‭\t‬‭B‬‭\t‬‭C‬‭\t‬‭Expected‬‭\t‬‭ Actual‬‭"‬‭<<‬‭endl‬‭;‬
b‭ ool‬‭flag‬‭=‬‭false‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭testCases‬‭.‬‭size‬‭();‬‭i‭+
‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭T ‬ est Case‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭‬‭\t‬‭‬‭‬‭"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭<<‬‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‬‭][‬‭1‬‭]‬‭<<‬
‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭2‬‭]‬‭<<‬‭"\t‬‭"‬‭<<‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭<<‬‭"\t\t"‬‭<<‬‭M3_Code‬‭(‭t‬estCases‬‭[‭i‬‭]‬ ‬‭)‬‭<<‬
‭endl‬‭;‬
‭if‬‭(‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭!=‬‭M3_Code‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭&&‬‭flag‬‭==‬‭false‬‭)‬‭{‬
‭killed‬‭++;‬
‭flag‬‭=‬‭true‬‭;‬
‭}‬
‭}‬

‭if‬‭(‬‭flag‬‭==‬‭true‬‭)‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M‬ utant Killed‬‭";‬
‭else‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M
‬ utant not Killed‬‭";‬
‭}‬

‭void‬‭M4‬‭(‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭testCases‬‭)‬‭{‬
‭cout‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ---------------------------------------------------‬‭---- ‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ Mutant 4‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"\t\t‬‭ A‬‭\t‬‭B‬‭\t‬‭C‬‭\t‬‭Expected‬‭\t‬‭ Actual‬‭"‬‭<<‬‭endl‬‭;‬

b‭ ool‬‭flag‬‭=‬‭false‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭testCases‬‭.‬‭size‬‭();‬‭i‭+
‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭T ‬ est Case‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭‬‭\t‬‭‬‭‬‭"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭<<‬‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‬‭][‬‭1‬‭]‬‭<<‬
‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭2‬‭]‬‭<<‬‭"\t‬‭"‬‭<<‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭<<‬‭"\t\t"‬‭<<‬‭M4_Code‬‭(‭t‬estCases‬‭[‭i‬‭]‬ ‬‭)‬‭<<‬
‭endl‬‭;‬
‭if‬‭(‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭!=‬‭M4_Code‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭&&‬‭flag‬‭==‬‭false‬‭)‬‭{‬
‭killed‬‭++;‬
‭flag‬‭=‬‭true‬‭;‬
‭}‬
‭}‬

‭if‬‭(‬‭flag‬‭==‬‭true‬‭)‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M‬ utant Killed‬‭";‬
‭else‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M
‬ utant not Killed‬‭";‬
‭}‬

‭void‬‭M5‬‭(‬‭vector‬‭<‬‭vector‬‭<‬‭int‬‭>>‬‭testCases‬‭)‬‭{‬
‭cout‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ----------------------------------------------------‬‭‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ Mutant 5‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"\t\t‬‭ A‬‭\t‬‭B‬‭\t‬‭C‬‭\t‬‭Expected‬‭\t‬‭ Actual‬‭"‬‭<<‬‭endl‬‭;‬

b‭ ool‬‭flag‬‭=‬‭false‬‭;‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭testCases‬‭.‬‭size‬‭();‬‭i‭+
‬ +)‬‭{‬
‭cout‬‭<<‬‭"‭T ‬ est Case‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭‬‭\t‬‭‬‭‬‭"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭<<‬‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‬‭][‬‭1‬‭]‬‭<<‬
‭"\t"‬‭<<‬‭testCases‬‭[‭i‬‭]‬ [‬‭2‬‭]‬‭<<‬‭"\t‬‭"‬‭<<‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭<<‬‭"\t\t"‬‭<<‬‭M5_Code‬‭(‭t‬estCases‬‭[‭i‬‭]‬ ‬‭)‬‭<<‬
‭endl‬‭;‬
‭if‬‭(‬‭correct‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭!=‬‭M5_Code‬‭(‭t‬estCases‬‭[‭i‬‬‭]‭)‬ ‬‭&&‬‭flag‬‭==‬‭false‬‭)‬‭{‬
‭killed‬‭++;‬
‭flag‬‭=‬‭true‬‭;‬
‭}‬
‭}‬

‭if‬‭(‬‭flag‬‭==‬‭true‬‭)‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M‬ utant Killed‬‭";‬
‭else‬
‭cout‬‭<<‬‭endl‬‭<<‬‭"‭M
‬ utant not Killed‬‭";‬
‭}‬

‭int‬‭main‬‭()‬‭{‬
‭cout‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ---------------------------------------------------‬‭---- ‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ MUTATION TESTING‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"‭E ‬ nter number of test cases:‬‭";‬
‭int‬‭N‬‭;‬
‭cin‬‭>>‬‭N‬‭;‬
‭vector‬‭<‭v‬ ector‬‭<‬‭int‬‭>>‬‭testCases‬‭(‬‭N‭,‬‬‭vector‬‭<‭i‬nt‬‭>(‬‭3‬‭,‬‭0‬‭));‬
‭for‬‭(‬‭int‬‭i‬‭=‬‭0‬‭;‬‭i‬‭<‬‭N‬‭;‬‭i‬‭++)‬‭{‬
‭cout‬‭<<‬‭"‭E ‬ nter test case‬‭"‬‭<<‬‭i‬‭+‬‭1‬‭<<‬‭"‬‭:‬‭";‬
‭cin‬‭>>‬‭testCases‬‭[‭i‬‭]‬ [‬‭0‬‭]‬‭>>‬‭testCases‬‭[‭i‬‬‭][‬‭1‬‭]‬‭>>‬‭testCases‬‭[‬‭i‭]‬ [‬‭2‬‭]‭;‬‬
‭}‬

‭ 1‬‭(‬‭testCases‬‭);‬
M
‭M2‬‭(‬‭testCases‬‭);‬
‭M3‬‭(‬‭testCases‬‭);‬
‭M4‬‭(‬‭testCases‬‭);‬
‭M5‬‭(‬‭testCases‬‭);‬

c‭ out‬‭<<‬‭endl‬‭<<‬‭endl‬‭<<‬‭"‭-‬ ---------------------------------------------------‬‭---- ‬
‭--------------------------‬‭\n";‬
‭cout‬‭<<‬‭"‬‭ MUTATION SCORE‬‭"‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"‭T ‬ otal Mutants:‬‭"‬‭<<‬‭5‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"‭M‬ utants Killed:‬‭"‬‭<<‬‭killed‬‭<<‬‭endl‬‭;‬
‭cout‬‭<<‬‭"‭M
‬ utation Score:‬‭"‬‭<<‬‭killed‬‭/‬‭5.0‬‭<<‬‭endl‬‭;‬
‭return‬‭0‬‭;‬
‭}‬

‭OUTPUT‬‭: -‬

You might also like