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
Given that events A and b are independent p(A) =0.60 and P(B)=0.30, what is P(A and B)?
myrzilka [38]
P(a)*p(b)=0.6*0.3=0.18
3 0
3 years ago
Simplify this expression.<br> (100 + 4z)20
Serga [27]
The answer is 2000+80z
7 0
3 years ago
Read 2 more answers
On a graph, the solution to a system of linear equations is represented by __________.
Eduardwww [97]

Answer:

Step-by-step explanation:

The solution for a system of equations when expressed graphically is coordinate of the point where the two graphs intersect.

4 0
3 years ago
Read 2 more answers
there are 20 guests at a party. the host has 8 gallons of punch. he estimates that each guest will drink 2 cups of punch. if he
Rina8888 [55]

Answer: He will have 88 cups of punch left over

Step-by-step explanation:

6 0
3 years ago
Read 2 more answers
A student estimated that it would take 3 hours to write a book report, but it actually took her 5 hours. what is the percent err
Masteriza [31]

40 percent 3/5 equals 60, 5/5 equals 100, 100-60 equals 40 percent

4 0
3 years ago
Other questions:
  • Given triangle IMJ with altitude JL, JL = 32, and IL =24, find IJ, JM, LM, and IM.
    7·2 answers
  • When you have two shapes to compare on a coordinate plane, you can determine the scale factor, knowing that the transformation w
    15·2 answers
  • Name a point that is (radical 2) away from (-1,5).
    13·1 answer
  • What is the width of a rectangular room with an are 90 square feet and a length of 9 feet
    5·2 answers
  • Determine what type of quadrilateral ABCD is, given the points. A(2,0) B(3,5) C(5,0) D(6,5) Rhombus Parallelogram Rectangle I kn
    11·2 answers
  • Of the shape shown below.<br> units?<br> Show Calculator<br> What is the answer
    10·1 answer
  • In the quadrilateral below, Angle A is-congruent-to angle C, and Angle B is-congruent-to angle D.
    13·2 answers
  • Riley is going to buy a television for $444. 50 plus tax. The sales tax is 6.5%.
    11·1 answer
  • If the diameter of the circle is 24 cm, find its area correct to one decimal place.
    11·1 answer
  • What is the slope-intercept equation of the line below?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!