code:
{
int sum=0,square_sum=0,cube_sum=0;
int t1,t2;
for(int i=1;i<=20;i++)
{
sum += i;
t1 = i*i;
square_sum += t1;
t2 = t1*i;
cube_sum += t2;
}
}
1. Create the algorithm for the following problem. Considering the first 20 natural numbers, calculate the...
design an algorithm that will display to the screen the first 20 numbers, with their squares and cubes, as follows:
1. A flowchart is designed to calculate the sum of the first 33 natural numbers. What type of Flow Chart structure this design is? Explain your answer
Can I please have a simple pseudocode algorithm of this problem. 1 Design an algorithm that will read a series of 50 integers at the terminal. The first integer is special, as it indicates how many more integers will follow. Your algorithm is to calculate and print the sum and average of the integers, excluding the first integer, and display these values to the screen.
Q1. Write an algorithm (pseudocode or flowchart) for the following problem. Input: Eight integers Output: the sum of even numbers only. Example: Let the eight integers are 2, 9, 3, 20,5,17, 10, 6 then S = 2+20+10+6 = 38
ANSWER USING JAVA CODE (1)The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. Find the difference between the...
Problem 1: regarding Binary numbers, create an algorithm (flowchart ) that reads a 4-bit binary number from the keyboard as a string and then converts it into a decimal number. For example, if the input is 1100, the output should be 12. (Hint: Break the string into substrings and then convert each substring to a value for a single bit. If the bits are b0, b1, b2, and b3, the decimal equivalent is 8b0+ 4b1+ 2b2+ b3.) Problem 2: Suppose...
1.The following pseudocode algorithm is used to calculate the average of two numbers. Perform a desk check on this algorithm assuming the firstValue is 12.5 and the secondValue is 7.5. You should use a table to show your answer. L1: Program AverageCalculator; L2: Data firstValue as float; L3: Data SecondValue as float; L4: Data average as float; L5: Output “Enter the first Number”; L6: Input firstValue; L7: Output “Enter the second Number”; L8: Input secondValue; L9: average = (firstValue+secondValue)/2; L10:...
8. Design a flowchart for sorting the following numbers using "Bubble Sort" algorithm. (20) 74 101 5 [74 10 1 5; N= length of array, a Hints: There are 5 (five) numbers. Let us assume the array, a Start drawing the flowchart as follows: Start For Input ac[74 10 1 5) Length of a False For k-0kcN-2:k-k+1 True 8. Design a flowchart for sorting the following numbers using "Bubble Sort" algorithm. (20) 74 101 5 [74 10 1 5; N=...
How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button "problem 2" is clicked, a JavaScript function equivalent to the following flowchart should execute. In other words, your task here is to translate the following flowchart to JavaScript code in P2<yourname>: start sum1 0 sum2 0 P i0 i< 3 iei+1 num sum1 sum1 + num F i <3 ii+1 sum1 sum2 "no" num "yes" sum2 sum2 + num end Hint: for input, use...
Subject: Algorithm need this urgent please thank you. 4. Give pseudocode for an algorithm that will solve the following problem. Given an array A[1..n) that contains every number between 1 and n +1 in order, except that one of the numbers is missing. Find the miss sorted ing mber. Your algorithm should run in time (log n). (Hint: Modify Binary search). A pseudocode means an algorithm with if statements and loops, etc. Don't just write a paragraph. Also, if your...