1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Trava [24]
3 years ago
11

Write a for loop that assigns summedvalue with the sum of all odd values from 1 to usernum. assume usernum is always greater tha

n or equal to 1.
Mathematics
1 answer:
Lapatulllka [165]3 years ago
5 0
// Input value is usernum.
// This code snippet sums 1 + 3 + 5 + ... + usernum
//  The answer is stored in the variable summedvalue.

N = (int) (usernum+1)/2;    // maximum number of integers to be summed
int *v = malloc(N*sizeof(int));     //  allocate storage for array v

// Calculate the number of loop counts and assign array v..
count = 0;
k = 1;
while (1) {
       if (k>usernum) {   //  do not extend v beyond usernum
          break;
          }
       v(count) = k;        //  assign an odd integer to v, including usenum
       count++;
       k += 2;                //  k is an odd number
       if k>usernum {          // handle usernum as odd or even
          k = usernum;
          } 
 }
n = count;          // the size of array v.

// Calculate the sum in a for loop
summedvalue  = 0;               // initialize summedvalue
for (i=0; i<=n; i++) {
     summedvalue += v(i);
    }


You might be interested in
The perimeter of a rectangle garden is 348 feet if the length of the garden is 93 feet what is the width?
Ber [7]
The width is 81 feet. 
93(2)+81(2)=348
3 0
3 years ago
Read 2 more answers
Thomas bought several paintbrushes for $4 each. He paid with a $20 bill. The expression 20 – 4n is used to determine how much ch
Tresset [83]

Answer:

the variable n represents how many of the product thomas bought

Step-by-step explanation:

20 dollars is the initial amount of money, and for every paintbrush, you have to subtract 4 dollars from thomas's initial amount, and the result of the subtraction is the amount of change he will recieve.

4 0
3 years ago
Tyler needs to complete this table for his consumer science class. He knows that 1 tablespoon contains 3 teaspoons and that 1 cu
aalyn [17]

Answer:

1 pint=32    1 quart=64    1 gallon=256

Step-by-step explanation:

5 0
3 years ago
Chords AB and CB intersect at E in circle O, as shown in the diagram below. Secant
Jobisdone [24]

Answer:

Step-by-step explanation:

4 0
2 years ago
Which of the following statements will complete step #3 in the algebraic proof? Given 5(x + 3) – 2 = 13 step-by-step
Elena L [17]

Answer:

x=2

Step-by-step explanation:

5(x+3)-2=13

5(x+3)=15

x+3=5

x=2

4 0
3 years ago
Read 2 more answers
Other questions:
  • A chemistry teacher needs to mix a 30% salt solution with a 70% salt solution to make 20 qt of a 40% salt solution. How many qua
    7·1 answer
  • The following table shows the number of hours some students in two neighborhoods spend walking to school each week:
    5·1 answer
  • Simplify the expression using the order of operations show all your work 150- (4²+4) ÷ 2
    15·2 answers
  • Using the graph, determine the coordinates of the x-intercepts of the parabola.
    13·1 answer
  • Hailey wants to put a skirt around her desk to hide all her computer equipment and cords. She measured her desk, found the dimen
    13·1 answer
  • Claire purchases a new dress for the prom. The dress is priced $160, but it is on sale for 30% off. Claire’s aunt works at the s
    14·1 answer
  • . Osteen has 32 marbles in his collection. 18 of his marbles are red, four are blue, and the rest are
    10·1 answer
  • PLEASE HELP WILL MARK BRAINLIEST THANK YOU
    6·1 answer
  • To rent a paint sprayer at the hardware store, there is a set fee and an hourly rate. The rental cost, c, can be determined usin
    8·1 answer
  • Pls help]ppppppppp me
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!