Answer:
The algorithm is as follows:
Input x
sum_a = 0
sum_b = 0
sum_c = 0
for i = 0 to 20
sum_a = sum_a + x^i
sum_b = sum_b + (-x)^i
sum_c = sum_c + x^i/(i+1)
print sum_a, sum_b, sum_c
Explanation:
Required
An algorithm to solve (a), (b) and (c)
For Series (a):
This series is a geometric progression and the common ratio is x
i.e.
So, the sum of the series is:
Sum = Previous Sums + x^i --- where i is between 0 and 20 (inclusive)
For Series (b):
This series is a geometric progression and the common ratio is -x
i.e.
So, the sum of the series is:
Sum = Previous Sums + (-x^i) --- where i is between 0 and 20 (inclusive)
For Series (c):
This series is a neither arithmetic nor geometric progression.
It obeys the following rule:
--- where i is between 0 and 20 (inclusive)
So, the sum of the series is:
Sum = Previous Sums +
Answer:
Option(c) i.e "sequence " is the correct answer for the given question.
Explanation:
In the sequence, the statement or instruction is executed in the sequence manner i.e one after another. In the sequence structure, the instruction is executed in the predetermined order and no instruction are skipped sometimes the sequence structure takes too many times when they are more instruction in a single module.
For Example : Following are the program in c++ of sequence control structure
#include<iostream.h> // header file
using namespace std; // namespace
int main() // main method
{
int a=100; // variable declaration
c=a+100;
cout<<c; // display c
return(0);
}
Output:100
In the above program the instruction a=100,c=a+100 and display c is executed in the sequence manner.
In the Option(a),Option(b) and Option(d) instruction are not executed in one after another so these are incorrect answers.
The person designing the game
Answer:
The function in Python is as follows:
def search_file(filename,mystring):
my_dict = {}
count = 0
file = open(filename)
lines = file.readlines()
for line in lines:
count+=1
if mystring.lower() in line.lower():
my_dict[count] = line.rstrip('\n')
return my_dict
Explanation:
This defines the function
def search_file(filename,mystring):
This initializes an empty dictionary
my_dict = {}
This initializes the number of lines to 0
count = 0
This opens the file
file = open(filename)
This reads the lines of the file
lines = file.readlines()
This iterates through the lines
for line in lines:
This increments the number line
count+=1
This checks if the string exists in the line
if mystring.lower() in line.lower():
If yes, the line number and the string are added to the dictionary
my_dict[count] = line.rstrip('\n')
This returns the dictionary
return my_dict
Answer:i They automatically display as the first row or column.
Explanation:Go to the "Insert" tab on the Excel toolbar, and then click the “Header & Footer” button in the Text group to start the process of adding a header. Excel changes the document view to a Page Layout view. Click on the top of your document where it says “Click to Add Header,” and then type the header for your document.