Answer:
d
Explanation:
cause people need a care for there incedents that not expected thats why people need help prevent from a risk to save people lives
The intention of this problem is to analyze a user input word, and display the letter that it starts with (book → B).
a. Create a function prototype for a function that accepts a word less than 25 characters long, and return a character.
b. Write the function definition for this function that evaluates the input word and returns the letter that the word starts with in capital letter (if it’s in small letters).
c. Create a function call in the main function, and use the function output to print the following message based on the input from the user. (Remember to have a command prompt in the main function requesting the user to enter any word.)
Computer starts with the letter C.
Summer starts with the letter S.
d. Make sure to consider the case where a naughty user enters characters other than the alphabet to form a word and display a relevant message.
%sb$ is not a word.
$500 is not a word.
e. Have the program process words until it encounters a word beginning with the character
Answer:
Here is the C++ program:
#include<iostream> // to use input output functions
using namespace std; //to identify objects like cin cout
void StartChar(string str) { // function that takes a word string as parameter and returns the first letter of that word in capital
int i;
char c;
do //start of do while loop
{
for (int i = 0; i < str.length(); i++) { //iterates through each character of the word str
if(str.length()>25){ //checks if the length of input word is greater than 25
cout<<"limit exceeded"; } //displays this message if a word is more than 25 characters long
c = str.at(i); // returns the character at position i
if (! ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) ) ) { //checks if the input word is contains characters other than the alphabet
cout<<str<<" is not a word!"<<endl; break;} //displays this message if user enters characters other than the alphabet
if (i == 0) { //check the first character of the input word
str[i]=toupper(str[i]); //converts the first character of the input word to uppercase
cout<<str<<" starts with letter "<<str[i]<<endl; } // prints the letter that the word starts with in capital letter
} cout<<"Enter a word: "; //prompts user to enter a word
cin>>str; //reads input word from user
}while(str!="#"); } //keeps prompting user to enter a word until the user enters #
int main() //start of the main() function body
{ string str; //declares a variable to hold a word
cout<<"Enter a word: "; //prompts user to enter a word
cin>>str; //reads input word from user
StartChar(str); } //calls function passing the word to it
Explanation:
The program prompts the user to enter a word and then calls StartChar(str) method by passing the word to the function.
The function StartChar() takes that word string as argument.
do while loop starts. The for loop inside do while loop iterates through each character of the word string.
First if condition checks if the length of the input word is greater than 25 using length() method which returns the length of the str. For example user inputs "aaaaaaaaaaaaaaaaaaaaaaaaaaa". Then the message limit exceeded is printed on the screen if this if condition evaluates to true.
second if condition checks if the user enters anything except the alphabet character to form a word. For example user $500. If this condition evaluates to true then the message $500 is not a word! is printed on the screen.
Third if condition checks if the first character of input word, convert that character to capital using toupper() method and prints the first letter of the str word in capital. For example if input word is "Computer" then this prints the message: Computer starts with the letter C in the output screen.
The program keeps prompting the user to enter the word until the user enters a hash # to end the program.
The output of the program is attached.
Diverting an attacker from accessing critical systems, collecting information about the attacker's activity and encouraging the attacker to stay on the system long enough for administrators to respond. These are all benefits of what network appliance?
Answer:
Honeypot is the correct answerExplanation:
A computer system that is meant to mimic the likely targets of cyber attacks is called honeypot. It is used to deflect the attackers from a legitimate target and detect attacks. It also helps to gain info about how the cyber criminals operate. They have been around for decades, it works on the philosophy that instead of searching for attackers, prepare something that would attract them. It is just like cheese-baited mousetraps. Cyber criminals get attracted towards honeypots by thinking that they are legitimate targets.
When working with the instruction LAHF, the lower eight bits of the EFLAGS register will wind up getting moved into the
hellohellohellohello
what is the role of media in our society, and how can we become responsible consumers producers of news and information in the digital age?
1.Own your image, personal information and how these are used.Pay close attention to the 2.Terms of Use on apps and websites. ...
3.Obtain permissions when posting videos or 4.images of others on your networks. ...
Scrub your accounts. ...
5.Password diligence. ...
Spread love, not hate.
What is a disruptive technology? Give an example of an aspect of society that has been impacted by technological change.
Answer:
A disruptive technology sweeps away the systems or habits it replaces because it has attributes that are recognizably superior. Recent disruptive technology examples include e-commerce, online news sites, ride-sharing apps, and GPS systems.
What caused the substantial schedule delay of software development for the Jaguar project? (b) How did the software problem impact the project? (c) If you were the project manager, what would you have done differently to prevent the software problem from happening?
Answer:
ES LA B
Explanation:
Draw the binary search tree that results from starting with an empty tree and
a. adding 50 72 96 94 26 12 11 9 2 10 25 51 16 17 95
b. adding 95 17 16 51 25 10 2 9 11 12 26 94 96 72 50
c. adding 10 72 96 94 85 78 80 9 5 3 1 15 18 37 47
d. adding 50 72 96 94 26 12 11 9 2 10, then removing 2 and 94
e. adding 50 72 96 94 26 12 11 9 2 10, then removing 50 and 26
f. adding 50 72 96 94 26 12 11 9 2 10, then removing 12 and 72
Answer:
See the attached document for answer.
Explanation:
See the attached document for the explanation.
Define a function print_total_inches, with parameters num_feet and num_inches, that prints the total number of inches. Note: There are 12 inches in a foot. Sample output with inputs: 58 Total inches: 68 def print_total_inches (num_feet, hum_inches): 2 str1=12 str2=num_inches 4 print("Total inches:',(num_feet*strl+str2)) 5 print_total_inches (5,8) 6 feet = int(input) 7 inches = int(input) 8 print_total_inches (feet, inches)
I'll pick up your question from here:
Define a function print_total_inches, with parameters num_feet and num_inches, that prints the total number of inches. Note: There are 12 inches in a foot.
Sample output with inputs: 5 8
Total inches: 68
Answer:
The program is as follows:
def print_total_inches(num_feet,num_inches):
print("Total Inches: "+str(12 * num_feet + num_inches))
print_total_inches(5,8)
inches = int(input("Inches: "))
feet = int(input("Feet: "))
print_total_inches(feet,inches)
Explanation:
This line defines the function along with the two parameters
def print_total_inches(num_feet,num_inches):
This line calculates and prints the equivalent number of inches
print("Total Inches: "+str(12 * num_feet + num_inches))
The main starts here:
This line tests with the original arguments from the question
print_total_inches(5,8)
The next two lines prompts user for input (inches and feet)
inches = int(input("Inches: "))
feet = int(input("Feet: "))
This line prints the equivalent number of inches depending on the user input
print_total_inches(feet,inches)
Answer:
Written in Python:
def print_total_inches(num_feet,num_inches):
print("Total inches: "+str(12 * num_feet + num_inches))
feet = int(input())
inches = int(input())
print_total_inches(feet, inches)
Explanation:
1)
Set numMatches to the number of elements in userValues (having NUM_VALS elements) that equal matchValue. Ex: If matchValue = 2 and userVals = {2, 2, 1, 2}, then numMatches = 3.
#include
int main(void) {
const int NUM_VALS = 4;
int userValues[NUM_VALS];
int i = 0;
int matchValue = 0;
int numMatches = -99; // Set numMatches to 0 before your for loop
userValues[0] = 2;
userValues[1] = 2;
userValues[2] = 1;
userValues[3] = 2;
matchValue = 2;
/* Your solution goes here */
printf("matchValue: %d, numMatches: %d\n", matchValue, numMatches);
return 0;
}
2)Write a for loop to populate array userGuesses with NUM_GUESSES integers. Read integers using scanf. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then userGuesses is {9, 5, 2}.
#include
int main(void) {
const int NUM_GUESSES = 3;
int userGuesses[NUM_GUESSES];
int i = 0;
/* Your solution goes here */
return 0;
}
3)Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8.
#include
int main(void) {
const int NUM_VALS = 4;
int testGrades[NUM_VALS];
int i = 0;
int sumExtra = -9999; // Initialize to 0 before your for loop
testGrades[0] = 101;
testGrades[1] = 83;
testGrades[2] = 107;
testGrades[3] = 90;
/* Your solution goes here */
printf("sumExtra: %d\n", sumExtra);
return 0;
}
4)Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = {90, 92, 94, 95}, print:
90, 92, 94, 95
Note that the last element is not followed by a comma, space, or newline.
#include
int main(void) {
const int NUM_VALS = 4;
int hourlyTemp[NUM_VALS];
int i = 0;
hourlyTemp[0] = 90;
hourlyTemp[1] = 92;
hourlyTemp[2] = 94;
hourlyTemp[3] = 95;
/* Your solution goes here */
printf("\n");
return 0;
}
Answer:
1)
for(i = 0; i < NUM_VALS; ++i) {
if(userValues[i] == matchValue) {
numMatches++; } }
2)
for (i = 0; i < NUM_GUESSES; i++) {
scanf("%d", &userGuesses[i]); }
for (i = 0; i < NUM_GUESSES; ++i) {
printf("%d ", userGuesses[i]); }
3)
sumExtra = 0;
for (i = 0; i < NUM_VALS; ++i){
if (testGrades[i] > 100){
sumExtra = testGrades[i] - 100 + sumExtra; } }
4)
for (i = 0; i < NUM_VALS; ++i) {
if (i<(NUM_VALS-1))
printf( "%d,", hourlyTemp[i]);
else
printf("%d",hourlyTemp[i]); }
Explanation:
1) This loop works as follows:
1st iteration:
i = 0
As i= 0 and NUM_VALS = 4 This means for condition i<NUM_VALS is true so the body of loop executes
if(userValues[i] == matchValue) condition checks if element at i-th index position of userValues[] array is equal to the value of matchValue variable. As matchValue = 2 and i = 0 So the statement becomes:
userValues[0] == 2
2 == 2
As the value at 0th index (1st element) of userValues is 2 so the above condition is true and the value of numMatches is incremented to 1. So numMatches = 1
Now value of i is incremented to 1 so i=1
2nd iteration:
i = 1
As i= 1 and NUM_VALS = 4 This means for condition i<NUM_VALS is true so the body of loop executes
if(userValues[i] == matchValue) condition checks if element at i-th index position of userValues[] array is equal to the value of matchValue variable. As matchValue = 2 and i = 1 So the statement becomes:
userValues[1] == 2
2 == 2
As the value at 1st index (2nd element) of userValues is 2 so the above condition is true and the value of numMatches is incremented to 1. So numMatches = 2
Now value of i is incremented to 1 so i=2
The same procedure continues at each iteration.
The last iteration is shown below:
5th iteration:
i = 4
As i= 4 and NUM_VALS = 4 This means for condition i<NUM_VALS is false so the loop breaks
Next the statement: printf("matchValue: %d, numMatches: %d\n", matchValue, numMatches); executes which displays the value of
numMatches = 3
2)
The first loop works as follows:
At first iteration:
i = 0
i<NUM_GUESSES is true as NUM_GUESSES = 3 and i= 0 so 0<3
So the body of loop executes which reads the element at ith index (0-th) index i.e. 1st element of userGuesses array. Then value of i is incremented to i and i = 1.
At each iteration each element at i-th index is read using scanf such as element at userGuesses[0], userGuesses[1], userGuesses[2]. The loop stops at i=4 as i<NUM_GUESSES evaluates to false.
The second loop works as follows:
At first iteration:
i = 0
i<NUM_GUESSES is true as NUM_GUESSES = 3 and i= 0 so 0<3
So the body of loop executes which prints the element at ith index (0-th) index i.e. 1st element of userGuesses array. Then value of i is incremented to i and i = 1.
At each iteration, each element at i-th index is printed on output screen using printf such as element at userGuesses[0], userGuesses[1], userGuesses[2] is displayed. The loop stops at i=4 as i<NUM_GUESSES evaluates to false.
So if user enters enters 9 5 2, then the output is 9 5 2
3)
The loop works as follows:
At first iteration:
i=0
i<NUM_VALS is true as NUM_VALS = 4 so 0<4. Hence the loop body executes.
if (testGrades[i] > 100 checks if the element at i-th index of testGrades array is greater than 100. As i=0 so this statement becomes:
if (testGrades[0] > 100
As testGrades[0] = 101 so this condition evaluates to true as 101>100
So the statement sumExtra = testGrades[i] - 100 + sumExtra; executes which becomes:
sumExtra = testGrades[0] - 100 + sumExtra
As sumExtra = 0
testGrades[0] = 101
So
sumExtra = 101 - 100 + 0
sumExtra = 1
The same procedure is done at each iteration until the loop breaks. The output is:
sumExtra = 8
4)
The loop works as follows:
At first iteration
i=0
i < NUM_VALS is true as NUM_VALS = 4 so 0<4 Hence loop body executes.
if (i<(NUM_VALS-1)) checks if i is less than NUM_VALS-1 which is 4-1=3
It is also true as 0<3 Hence the statement in body of i executes
printf( "%d,", hourlyTemp[i]) statement prints the element at i-th index i.e. at 0-th index of hourlyTemp array with a comma (,) in the end. As hourlyTemp[0] = 90; So 90, is printed.
When the above IF condition evaluates to false i.e. when i = 3 then else part executes which prints the hourlyTemp[3] = 95 without comma.
Same procedure happens at each iteration unless value of i exceeds NUM_VAL.
The output is:
90, 92, 94, 95
The programs along with their output are attached.
Write a query to display the department name, location name, number of employees, and the average salary for all employees in that department. Label the columns dname, loc, Number of People, and Salary, respectively.
Answer:
is hjs yen ; he jawjwjwjwjw
During the data transmission there are chances that the data bits in the frame might get corrupted. This will require the sender to re-transmit the frame and hence it will increase the re-transmission overhead. By considering the scenarios given below, you have to choose whether the packets should be encapsulated in a single frame or multiple frames in order to minimize the re-transmission overhead.
Justify your answer
Scenario A: Suppose you are using a network which is very prone to errors.
Scenario B: Suppose you are using a network with high reliability and accuracy.
1. Based on Scenario A, the packets should be encapsulated in multiple frames to minimize the re-transmission overhead.
This is because there will be the need to re-transmit the packets because the network environment is not reliable and accurate. Therefore, a single frame may be too costly when the need for re-transmission arises.
2. Based on Scenario B, the packets should be encapsulated in a single frame because of the high level of network reliability and accuracy.
There will not be further need to re-transmit the packets in a highly reliable and accurate network environment. This environment makes a single frame better.
Encapsulation involves the process of wrapping code and data together within a class so that data is protected and access to code is restricted.
With encapsulation, each layer:
provides a service to the layer above itcommunicates with a corresponding receiving nodeThus, in a reliable and accurate network environment, single frames should be used to enhance transmission and minimize re-transmission overhead.
Learn more about data encapsulation here: https://brainly.com/question/23382725
Assume a client calls an asynchronous RPC to a server, and subsequently waits until the server returns a result using another asynchronous RPC. Is this approach the same as letting the client execute a normal RPC
Answer:
This approach is not the same as letting the client execute a normal RPC
Explanation:
This approach is not the same as letting the client execute a normal RPC and this is because an asynchronous RPC sends an additional message across the network after the initial call/message is sent by the sender to the client. this additional message sent through the network is directed towards the sender of the initial call/message as an acknowledgement of the receipt of the initial message by the client .
synchronous RPC is made of two asychronous RPCs, hence the client executing a normal RPC will not establish a reliable communication between the client and the sender as asynchronous RPC would
EAPOL operates at the network layers and makes use of an IEEE 802 LAN, such as Ethernet or Wi-Fi, at the link level.
A. True
B. False
A machine on a 10 Mbps network is regulated by a token bucket algorithm with a fill rate of 3 Mbps. The bucket is initially filled to capacity at 3MB. How long can the machine transmit at the full 10 Mbps capacity
fill in the blank with the correct response
Answer:
regenerates
Explanation:
a hub regenerates it's signal bit by bit as it travels down the physical medium
While the Internet can be a great resource, the information is not always reliable, as anyone can post information. Select one: True False
Answer: True
Explanation: Because anyone can post something and it can be non reliable
You are required to install a printer on a Windows 7 Professional x86 workstation. Which print driver do you need to complete the installation?
Answer:
It depends on the model of the printer you want to install. Recent printers when connected to the computer install themselves searching for the drivers needed on the internet. Anyway, you can always google the word "driver" plus the model of your printer and it will surely appear the driver you need from the the company's website of the printer
The print driver that you will need to complete the installation of a printer on Windows 7 Professional x86 workstation is; 32 bit driver
In windows 7 Professional, an x86 name architecture simply denotes a 32 - bit CPU and operating system while x64 will refer to a 64-bit CPU and operating system.
Thus, since we want to install a printer on a Windows 7 Professional x86 workstation, it means we have to use a print driver that is 32 - bit.
Read more about 32 bits at; https://brainly.com/question/19667078
Write a Visual Basic Program to display factorial series upto nth term 1! 2! 3! 4! ...!
Answer:
n = n(n-1)!
Explanation:
expanding the factorial we get;
1!=1.
2!=2x1.
3!=3x2x1.
4!=4x3x2x1.
5!=5x4x3x2x1.
we can rewrite the above factorials as:
1!=1
2!=2!
3!=2!x3
4!=4x3!
5!=5x4!
the pattern applies such that if we have n th number we get it's factorial as;
n = n(n-1)!
Vehicles driving in the opposite direction on a multi-lane highway with opposite lanes separated by a painted line must stop for school buses.
A. TRUE
B. FALSE
Briefly describe the importance of thoroughly testing a macro before deployment. What precautions might you take to ensure consistency across platforms for end users?
Answer:
Answered below
Explanation:
A macro or macroinstruction is a programmable pattern which translates a sequence of inputs into output. It is a rule that specifies how a certain input sequence is mapped to a replacement output sequence. Macros makes tasks less repetitive by representing complicated keystrokes, mouse clicks and commands.
By thoroughly testing a macro before deployment, you are able to observe the flow of the macro and also see the result of each action that occurs. This helps to isolate any action that causes an error or produces unwanted results and enable it to be consistent across end user platforms.
Each time we add another bit, what happens to the amount of numbers we can make?
Answer:
When we add another bit, the amount of numbers we can make multiplies by 2. So a two-bit number can make 4 numbers, but a three-bit number can make 8.
The amount of numbers that can be made is multiplied by two for each bit to be added.
The bit is the most basic unit for storing information. Bits can either be represented as either 0 or 1. Data is represented by using this multiple bits.
The amount of numbers that can be gotten from n bits is given as 2ⁿ.
Therefore we can conclude that for each bit added the amount of numbers is multiplied by two (2).
Find more about bit at: https://brainly.com/question/20802846
A text file has been transferred from a Windows system to a Unix system, leaving it with the wrong line termination. This mistake can be corrected by
Answer:
Text to ASCII Transfer
Explanation:
A direct-mapped cache holds 64KB of useful data (not including tag or control bits). Assuming that the block size is 32-byte and the address is 32-bit, find the number of bits needed for tag, index, and byte select fields of the address.
Answer:
A) Number of bits for byte = 6 bits
B) number of bits for index = 17 bits
C) number of bits for tag = 15 bits
Explanation:
Given data :
cache size = 64 kB
block size = 32 -byte
block address = 32 -bit
number of blocks in cache memory
cache size / block size = 64 kb / 32 b = 2^11 hence the number of blocks in cache memory = 11 bits = block offset
A) Number of bits for byte
[tex]log _{2} (6)^2[/tex] = 6 bits
B) number of bits for index
block offset + byte number
= 11 + 6 = 17 bits
c ) number of bits for tag
= 32 - number of bits for index
= 32 - 17 = 15 bits
After a new firewall is installed, users report that they do not have connectivity to the Internet. The output of the ipconfig command shows an IP address of 169.254.0.101. Which of the following ports would need to be opened on the firewall to allow the users to obtain an IP address? (Select TWO).
A. UDP 53
B. UDP 67
C. UDP 68
D. TCP 53
E. TCP 67
F. TCP 68
Answer:
B. UDP 67
C. UDP 68
Explanation:
In this scenario, after a new firewall is installed, users report that they do not have connectivity to the Internet. The output of the ipconfig command shows an IP address of 169.254.0.101. The ports that would need to be opened on the firewall to allow the users to obtain an IP address are both the UDP 67 and UDP 68. UDP is an acronym for user datagram protocol in computer networking and it is part of the transmission control protocol/internet protocol (TCP/IP) suite.
Generally, the standard Internet communications protocols which allow digital computers to transfer (prepare and forward) data over long distances is the TCP/IP suite.
Also, the UDP 67 and 68 ports is responsible for the connectionless framework which is typically being used by the dynamic host configuration protocol (DHCP) that is used to assign IP addresses to various computer users and manage their leases.
UDP 67 is the destination port for a DHCP server while the UDP 68 is the port number for the computer user (client).
Hence, for the users to have access to the internet or internet connectivity both UDP 67 and 68 must be opened on the firewall.
Given a number N, write a code to print all psoitive numbers less than N in which all adjacent digits differ by 1
Answer:
def lesser_adjacent_num ( N ):
N = int( N )
while N == True:
next = N - 1
print if next >= 0 ? next : break
Explanation:
The python function above called "lesser_adjacent_num" accepts an argument called "N" which is an integer. The function print the number "next" which is a number less than the N integer for every loop for the condition where N is not zero.
3. Which of the following is called address operator?
a)*
b) &
c).
d) %
Answer:
The Ampersand Symbol (Option B)
Explanation:
A 'address of operator' specifies that a given value that is read needs to be stored at the address of 'x'.
The address operator is represented by the ampersand symbol. ( & )
Hope this helps.
CHALLENGE ACTIVITY 3.1.2: Type casting: Computing average owls per zoo.
Assign avg_owls with the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4
Average owls per zoo: 2
1. num owls zooA= 1
2. num owls zooB = 2
3. numowlszooC = 4 -
4. num-zoos = 3
5. avg-owls 0.0
6.
7. Your solution goes here" Run
8.
Answer:
num_owls_zooA = 1
num_owls_zooB = 2
num_owls_zooC = 4
num_zoos = 3
avg_owls = 0.0
avg_owls = (num_owls_zooA + num_owls_zooB + num_owls_zooC) / num_zoos
print("Average owls per zoo: " + str(int(avg_owls)))
Explanation:
Initialize the num_owls_zooA, num_owls_zooB, num_owls_zooC as 1, 2, 4 respectively
Initialize the num_zoos as 3 and avg_owls as 0
Calculate the avg_owls, sum num_owls_zooA, num_owls_zooB, num_owls_zooC and divide the result by num_zoos
Print the avg_owls as an integer (Type cast the avg_owls to integer, int(avg_owls))
computer in education are used for teaching and learning aids
5.15 LAB: Count input length without spaces, periods, or commas Given a line of text as input, output the number of characters excluding spaces, periods, or commas. Ex: If the input is:
Answer:
Following are the code to this question:
userVal = input()#defining a variable userVal for input the value
x= 0#defining variable x that holds a value 0
for j in userVal:#defining for loop to count input value in number
if not(j in " .,"):#defining if block that checks there is no spaces,periods,and commas in the value
x += 1#increment the value of x by 1
print(x)#Print x variable value
Output:
Hello, My name is Alex.
17
Explanation:
In the above-given code, a variable "userVal" is defined that uses the input method for input the value from the user end, in the next line, an integer variable "x" is defined, hold value, that is 0, in this variable, we count all values.
In the next line, for loop is defined that counts string value in number and inside the loop an if block is defined, that uses the not method to remove spaces, periods, and commas from the value and increment the value of x by 1. In the last step, the print method is used, which prints the calculated value of the "x" variable.
Answer:
Explanation:#include <iostream>
#include<string>
using namespace std;
int main()
{
string str;
cout<<"Enter String \n";
getline(cin,str);/* getLine() function get the complete lines, however, if you are getting string without this function, you may lose date after space*/
//cin>>str;
int count = 0;// count the number of characeter
for (int i = 1; i <= str.size(); i++)//go through one by one character
{
if ((str[i]!=32)&&(str[i]!=44)&&(str[i]!=46))//do not count period, comma or space
{
++ count;//count the number of character
}
}
cout << "Number of characters are = "; //display
cout << count;// total number of character in string.
return 0;
}
}
Will the Python code below print something? And will it terminate?
def print_n(s, n):
if n > 0:
print(s)
print_n(s, n-1)
return n
n = 3
while print_n("hi", n):
print_n("there!", n)
n = 0
a. no and no
b. yes and no
c. no and yes
d. yes and yes
e. syntax error
Answer:
Yes and Yes
Explanation:
When programs are written without indentation; it becomes a problem to read;
I'll rewrite your program as follows:
def print_n(s, n):
if n > 0:
print(s)
print_n(s, n-1)
return n
n = 3
while print_n("hi", n):
print_n("there!", n)
n = 0
Using the above as a point of reference,
Yes, the program will run and Yes, it'll terminate;
Because n is initialized to 3 at line 6 (where the main starts);
The following is passed to the function; s = "hi" and n=3
This prints "hi", three times
s = "there" and n=3 is then passed to the function print_n, afterwards;
The function then prints "there" three times
Then, the program terminates