This question is not on answers, so if you plagiarize I will report. TWO major instructions before you start. Otherwise do
Posted: Sat Feb 19, 2022 3:23 pm
This question is not on answers, so if you plagiarize I
will report.
TWO major instructions before you start. Otherwise do
not start.
1) Use C language not C++.
2) We need to make sure that the solution is
compatible with CodeWarrior in Full Chip Simulation mode. Also
attach the typed code (NO HANDWRITTEN) and also attach the output
window from the CodeWarrior.
******That means we have to declare the following as
global: int lines, newlines;******
Lab Exercise: In a directly connected
telephone network, all telephones are connected and do not require
a central switching station to establish calls between two
telephones. The number of lines needed to maintain a directly
connected telephone network is given by:
no. of lines needed=n(n-1)/2
For example, directly connecting four telephones requires six
separate lines as shown in Figure below.
Adding a fifth telephone to this network requires an additional
4 lines for a total of 10 lines (=5*(5-1)/2).
Using the given formula, write a C program that
determines (a) the number of direct lines required for connecting
50 telephones and (b) the additional number of lines needed when 10
telephones are added to the existing network. Use four steps of
program development method.
SOLUTION:
Step 1 – Analyze the Problem
There are two inputs to the program:
number of existing telephones n = 50
number of additional telephones addln = 10
The outputs will be the number of existing lines: lines, and
additional lines: newlines
Step 2 – Find a solution
From the given algorithm, the number of lines is given by
numlines=n*(n-1)/2
By hand computation, number of existing lines =
?
Number of new lines = ?
We need to make sure that the solution is compatible
with CodeWarrior in Full Chip Simulation mode. That means we have
to declare the following as global: int lines,
newlines;
Step 3 – Code the Solution
Here goes your program template:
#include “hcs12.h”
int lines, newlines;
void main()
{
int n=50, addln=10;
/* insert rest of your code here */
while(1);
}
Copy and paste your full C code here:
Step 4 – Run
From running the code, copy and paste Debug window showing the
results here:
will report.
TWO major instructions before you start. Otherwise do
not start.
1) Use C language not C++.
2) We need to make sure that the solution is
compatible with CodeWarrior in Full Chip Simulation mode. Also
attach the typed code (NO HANDWRITTEN) and also attach the output
window from the CodeWarrior.
******That means we have to declare the following as
global: int lines, newlines;******
Lab Exercise: In a directly connected
telephone network, all telephones are connected and do not require
a central switching station to establish calls between two
telephones. The number of lines needed to maintain a directly
connected telephone network is given by:
no. of lines needed=n(n-1)/2
For example, directly connecting four telephones requires six
separate lines as shown in Figure below.
Adding a fifth telephone to this network requires an additional
4 lines for a total of 10 lines (=5*(5-1)/2).
Using the given formula, write a C program that
determines (a) the number of direct lines required for connecting
50 telephones and (b) the additional number of lines needed when 10
telephones are added to the existing network. Use four steps of
program development method.
SOLUTION:
Step 1 – Analyze the Problem
There are two inputs to the program:
number of existing telephones n = 50
number of additional telephones addln = 10
The outputs will be the number of existing lines: lines, and
additional lines: newlines
Step 2 – Find a solution
From the given algorithm, the number of lines is given by
numlines=n*(n-1)/2
By hand computation, number of existing lines =
?
Number of new lines = ?
We need to make sure that the solution is compatible
with CodeWarrior in Full Chip Simulation mode. That means we have
to declare the following as global: int lines,
newlines;
Step 3 – Code the Solution
Here goes your program template:
#include “hcs12.h”
int lines, newlines;
void main()
{
int n=50, addln=10;
/* insert rest of your code here */
while(1);
}
Copy and paste your full C code here:
Step 4 – Run
From running the code, copy and paste Debug window showing the
results here: