Answer:
/*C++ program that prompts user to enter the name of input file(input.txt in this example) and print the sum of the values in the file to console. If file dosnot exist, then close the program */
//header files
#include <fstream>
#include<string>
#include <iostream>
#include <cstdlib> //needed for exit function
using namespace std;
//function prototype
int fileSum(string filename);
int main()
{
string filename;
cout << "Enter the name of the input file: ";
cin >> filename;
cout << "Sum: " << fileSum(filename) << endl;
system("pause");
return 0;
}
/*The function fileSum that takes the string filename and
count the sum of the values and returns the sum of the values*/
int fileSum(string filename)
{
//Create a ifstream object
ifstream fin;
//Open a file
fin.open(filename);
//Initialize sum to zero
int sum=0;
//Check if file exist
if(!fin)
{
cout<<"File does not exist ."<<endl;
system("pause");
exit(1);
}
else
{
int value;
//read file until end of file exist
while(fin>>value)
{
sum+=value;
}
}
return sum;
}//end of the fileSum
Explanation:
This is a C++ program that prompts user to enter the name of input file(input.txt in this example) and print the sum of the values in the file to console. If file dosnot exist, then close the program.
Check attachment for sample output screenshot.
Answer:
Required memory size is 16k x 8
16k = 24 x 210 = 214
Hence, No. of address lines = 14
No. of data lines = 8
a) Size of IC 1024 x 1
Total number of ICs required = 16k x 8 / 1024 x 1 = 16 x 8 = 128
b) Size of IC 2k x 4
Total number of ICs required = 16k x 8 / 2k x 4 = 8 x 2 = 16
c) Size of IC 1k x 8
Total number of ICs required = 16k x 8 / 1k x 8 = 16 x 1 = 16
Explanation:
For a, 10 address lines from A0 to A9 are used to select any one of the memory location out of 1024 memory locations present in a IC.
For b, 11 address lines from A0 to A10 are used to select any one of the memory location out of 2k=2048 memory locations present in a IC.
For c, 10 address lines from A0 to A9 are used to select any one of the memory location out of 1k=1024 memory locations present in a IC.
Answer:
1. Open Shortest Path First (OSPF)
2. Border Gateway Protocol (BGP)
3. Routing and Remote Access Service (RRAS)
4. Frame relay
5. Synchronous
6. Virtual
7. Committed Information Rate (CIR)
8. Integrated Services Digital Network (ISDN)
9. Asynchronous Transfer Mode (ATM)
10. Basic Rate Interface (BRI).
Answer:
int costOfBusRental;
int maxBusRiders;
int costPerRider;
costPerRider = costOfBusRental/maxBusRiders;
Explanation:
The costPerRider is the total cost of renting the bus (costofBusRental) divided by all the bus users (maxBusRiders). So we declare the three variables to be of type int as required by the question.