Answer:
Following are the program in C++ language
#include <iostream> // header file
using namespace std; // namespace
int main() // main function
{
int number=0; // variable declaration
while(number>-1) // iterating the while loop
{
cout<<"body"<<endl; // dsiplay the statement
cin>>number; // Read the value by the user
}
cout<<endl<<"Done";// dsiplay the statement
return 0;
}
Output:
body
5
body
45
body
-8
Done
Explanation:
Following are the description of the statement
- Declared a variable "number" of int type and initialized with 0 to them
- iterating the while loop. In this loop print the message "body" and Read the value by the user in the "number" variable. This loop will be executed repeatedly until the user do not read the negative value.
- After the execution of the while loop, it prints the message "Done".
The code that examines all the strings in the input source and determines how long the longest string (or strings are) is the following:
total = 0;
% initial value is zero, in every while loop it will be incremented
while(input.hasNextInt()){
total += input.nextInt( );
}
Answer:
c.
Explanation:
I believe that in this scenario, the best option for this data would be a hash table using open addressing with 1,800 entries. Hash tables consume more memory than lists but it makes up for it with much faster response time speeds. This is because hash tables work on a key:value system therefore, the license plate can easily be grabbed from the database extremely quickly by just plugging in the plate number. Doing so will retrieve all of the saved information from that license plate. That is why hash tables have a constant time complexity of O(1)
/*
Since we have to check the first two options only as mentioned in last part of question the loop will work 2 times only and will compare the cost of first element and second and assign the healthoption accordingly
*/
for(int i =0;i<=1;i++){
if(annualCost[i]<annualCost[i+1]
best2 = healthOption[i]
else
best2 = healthOption[i+1]
}
Answer:
I am doing it with python.
Explanation:
nums = '9 -8 -7 -6 -5 -4 -2 0 1 5 9 6 7 4'
myfile = open('data.txt', 'w')
myfile.write(nums)
myfile.close()
myfile = open('data.txt', 'r')
num1 = (myfile.read())
num1 = num1.split()
print(num1)
print(type(num1))
for x in num1:
x = int(x)
if x < 0:
minus = open('dataminus.txt', 'a')
minus.write(str(x) + ' ')
minus.close()
elif x>= 0:
plus = open('dataplus.txt', 'a')
plus.write(str(x)+' ')
plus.close()