Added code and output for B5.
This commit is contained in:
parent
d024c4a714
commit
76ff4db369
35
Codes/Code-B5.cpp
Normal file
35
Codes/Code-B5.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void printSubnetMask(int prefixLength) {
|
||||||
|
int mask[4] = {0, 0, 0, 0};
|
||||||
|
for (int i = 0; i < prefixLength; ++i) {
|
||||||
|
mask[i / 8] |= (1 << (7 - (i % 8)));
|
||||||
|
}
|
||||||
|
cout << "Subnet Mask for /" << prefixLength << ": ";
|
||||||
|
cout << mask[0] << "." << mask[1] << "." << mask[2] << "." << mask[3] << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int prefixLength;
|
||||||
|
cout << "Enter the prefix length: ";
|
||||||
|
cin >> prefixLength;
|
||||||
|
|
||||||
|
if (prefixLength >= 0 && prefixLength <= 32) {
|
||||||
|
printSubnetMask(prefixLength);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "Invalid prefix length!" << std::endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
Enter the prefix length: 22
|
||||||
|
Subnet Mask for /22: 255.255.252.0
|
||||||
|
Enter the prefix length: 0
|
||||||
|
Subnet Mask for /0: 0.0.0.0
|
||||||
|
Enter the prefix length: 32
|
||||||
|
Subnet Mask for /32: 255.255.255.255
|
||||||
|
*/
|
BIN
Printable outputs/Output-B5.pdf
Normal file
BIN
Printable outputs/Output-B5.pdf
Normal file
Binary file not shown.
@ -46,8 +46,10 @@ This Git repository is a comprehensive resource for the Computer Networks and Se
|
|||||||
- [Output-A4](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Printable%20outputs/Output-A4.pdf)
|
- [Output-A4](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Printable%20outputs/Output-A4.pdf)
|
||||||
|
|
||||||
##### B5 - Subnetting and subnet mask
|
##### B5 - Subnetting and subnet mask
|
||||||
|
- [Code-B5](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Codes/Code-B5.cpp)
|
||||||
- [Handout-B5](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Handouts/Handout-B5.pdf)
|
- [Handout-B5](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Handouts/Handout-B5.pdf)
|
||||||
- [Write-up - B5](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Write-ups/Write-up%20-%20B5.pdf)
|
- [Write-up - B5](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Write-ups/Write-up%20-%20B5.pdf)
|
||||||
|
- [Output-B5](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Printable%20outputs/Output-B5.pdf)
|
||||||
|
|
||||||
##### B6 - Link state & distance vector
|
##### B6 - Link state & distance vector
|
||||||
- [Code-B6](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Codes/Code-B6.py)
|
- [Code-B6](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Codes/Code-B6.py)
|
||||||
|
Loading…
Reference in New Issue
Block a user