Using C++ allow the user to enter the IP address as four 8 bit unsigned integer values (just use 4 sequential CIN statements). The program should output the IP address as all 32 bits assigned into 2 variable sized groups (host group and network group) and outputted as 2 unsigned integer values from 1 bit to 31 bits each.
Example functionality:
Enter and IP address:
192
168
1
5
Which bit would you like to see: 21
Output should be 1
(Because the binary of the IP address is 11000000101010000000000100000101
******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As per HomeworkLib expert answering guidelines,Experts are supposed to
answer only certain number of questions/sub-parts in a post.Please
raise the remaining as a new question as per HomeworkLib
guidelines.
******************************************************************************************
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned int a,b,c,d;
cin>>a>>b>>c>>d;
long long int ans;
// ans= a<<24;
// cout<<ans<<" "<<endl;
// ans+=(b<<16);
// cout<<ans<<" "<<endl;
// ans+=(c<<8);
// cout<<ans<<" "<<endl;
// ans+=d;
// cout<<ans<<" "<<endl;
ans= (a<<24)+ (b<<16)+ (c<<8)+ d;
// // cout<<ans<<" "<<endl;
// long long int x,y;
// cout<<"How many bits in the network address:";
int bits;
cin>>bits;
// long long int left= pow(2,bits)-1;
// long long int right= pow(2,32-bits)-1;
// // cout<<ans<<" "<<bits<<"
"<<left<<" "<<right<<endl;
// x= (ans&(left<<(32-bits)))>>(32-bits);
// y= ans&(right);
// cout<<x<<","<<y;
cout<<((ans>>(bits))%2);
return 0;
}

Using C++ allow the user to enter the IP address as four 8 bit unsigned integer...
Write a program that allows the user to enter an unsigned integer (the maximum value of an unsigned 4-byte int is 232 = 4,294,967,296) and reverses its format (from little to big endian, or vice versa). Print out the user-entered number in hexadecimal and binary, reverse the endianness, and print the reverse in hexadecimal and binary. Integers in most machine architectures are represented in little endian format: the least significant byte is stored in the smallest address; for instance, the...
An IP address is a 32-bit number that uniquely identifies a host (computer or other device, such as a printer or router) on a TCP/IP network. IP addresses are normally expressed in dotted-decimal format, with four numbers separated by periods, such as 192.168.123.132. To understand how subnet masks are used to distinguish be- tween hosts, networks, and subnetworks, examine an IP address in binary notation. For example, the dotted-decimal IP address 192.168.123.132 is (in binary notation) the 32 bit num-...
Q1. Hierarchical IP Address 1.1 Give a non-network example of hierarchical addressing, and discuss how it reduces the amount of work needed in physical delivery. Do not use any example in the book, the postal service, or the telephone network.1.2 A firm is assigned the network part 128.171. It selects a 10-bit subnet part. a) Draw the bits for the four octets of the IP address of the first host on the first subnet. (Hint: as we don’t use all...
(1) Computer hosts usually have two addresses, an Internet Protocol (IP) address and an Ethernet Media Access Control (MAC) address. For the benefit of humans, the IP address is normally represented as a dotted decimal notation, such as 192.168.10.2. Each of the decimal octets in the address or a mask can be converted to 8 binary bits. Remember that the computer only understands binary bits. If all 4 octets were converted to binary, how many bits would there be? (2)...
(Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned intvariable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator....
This daily will allow you to practice more with the bit wise operators and shifts. Consider the following modification of the main program from daily 3: #include void set_flag(unsigned int* flag_holder, int flag_position); void unset_flag(unsigned int * flag_holder, int flag_position); int check_flag(unsigned int flag_holder, int flag_position); void display_32_flags(unsigned int flag_holder); int main(int argc, char* argv[]) { unsigned int flag_holder = 0; set_flag(&flag_holder, 3); set_flag(&flag_holder, 16); set_flag(&flag_holder, 31); display_32_flags(flag_holder); unset_flag(&flag_holder, 31); unset_flag(&flag_holder, 3); set_flag(&flag_holder, 9); display_32_flags(flag_holder); return 0; } Write the...
Introduction: This experiment studies the design of an 8-bit adder/subtractor circuit using VHDL capture. The experiment investigates the implementation of addition and subtraction operations with circuits. This lab uses the virtual simulation environment to validate the design practically in the FPGA board. Equipment: • This experiment requires Quartus Prime and the Intel's DE2-115 FPGA board. • All students should have the Intel QP and ModelSim-Intel-Starter-Edition softwares installed in personal computers. • VPN connection to UNB Network and remote desktop software...
Here is the code I made, but the test case is not working, it
goes wrong when the binary string convert to decimal. please
help.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <math.h>
#include <locale>
using namespace std;
// function for option 1
void decToBin(int number)
{
int array[16];
int i = 0;
for (int counter = 0;
counter < 16; counter++)
{
array[counter] = 0;
}
while (number > 0)
{...
check my answers for Networking I came up with these answers, can check my answers Question 1: General What data rate is needed to transmit an uncompressed 4" x 6" photograph every second with a resolution of 1200 dots per inch and 24 bits per dot (pixel)? 691,200 kb/s 28.8 kb/s 8.29 Mb/s 829 Mb/s Question 2: Layering "Layering" is commonly used in computer networks because (check all that apply): -It forces all network software to be written in ‘C’....