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
Select all of the following statments that are true
Nonamiya [84]

Answer:

A. -¾ + 0 = -¾

B. -¾ - ¾ = -(¾ + ¾)

C. ¾ - ¾ = ¾ + (-¾)

E. -¾ + ¾ = ¾ + (-¾)

F. -¾ + ¾ = 0

Step-by-step explanation:

Let's check each equation to determine whether they are true or false.

If what we have in the both sides are equal, then the equation is true, if they're not, them it is false.

✔️-¾ + 0 = -¾

Add everything on your left together

-¾ = -¾ (TRUE)

✔️-¾ - ¾ = -(¾ + ¾)

Add everything on both sides together respectively

(-3 - 3)/4 = -(3 + 3)/4

-6/4 = -6/4 (TRUE)

✔️¾ - ¾ = ¾ + (-¾)

0 = ¾ - ¾ (+ × - = -)

0 = 0 (TRUE)

✔️-¾ + ¾ = ¾ - (-¾)

0 = ¾ + ¾ (- × - = +)

0 = 6/4 (FALSE)

✔️-¾ + ¾ = ¾ + (-¾)

0 = ¾ - ¾ (+ × - = -)

0 = 0 (TRUE)

✔️-¾ + ¾ = 0

0 = 0 (TRUE)

6 0
3 years ago
A ferry departs from a port along the Sands River at 10:00 am. The ferry travels at a speed of 15 mph in still water and returns
jek_recluse [69]

Answer:

Speed of river's current = 5 mph

Step-by-step explanation:

Let 'd' be the distance covered  

 Let x be the speed of the rivers current

Speed upstream = 15-x

speed downstream = 15+x

Time = distance / speed

time upstream = \frac{d}{15-x}

time downstream = \frac{d}{15+x}

the ferry trip upstream takes twice as long as its return trip downstream

\frac{d}{15-x}= \frac{2d}{15+x}

divide both sides by d

\frac{1}{15-x}= \frac{2}{15+x}

cross multiply

15+x= 2(15-x)

15+x= 30-2x

Add 2x on both sideds

15+3x= 30

subtract 15 from both sides and divide by 3

3x=15

x=5

Speed of river's current = 5 mph

8 0
3 years ago
Can someone explain to me how to answer questions like this? I always get confused!
seropon [69]

Answer:

(b) 5k+1

Step-by-step explanation:

https://www.symbolab.com/solver/step-by-step/simplify%20%5Cfrac%7B30k%5E%7B2%7D%2B6k%7D%7B5k%2Bk%7D

5 0
3 years ago
M is directionly proptional to r squared
sergejj [24]

9514 1404 393

Answer:

  A) 504

  B) 8

Step-by-step explanation:

The statement of proportionality can be written as the equation ...

  m = kr²

Then we can find k from ...

  k = m/r² = 14/2² = 7/2

That is, ...

  m = (7/2)r²

__

Using this relation, we can find m for r=12:

  m = (7/2)·12² = 7·72

  m = 504 . . . for r = 12

__

And, we can use the same equation to solve for r when m=224.

  224 = 7/2·r²

  r² = 64

  r = √64

  r = 8 . . . for m = 224

4 0
3 years ago
How many odd numbers are greater than 30 and<br> less than 40?
Lana71 [14]

Answer:

5 odd numberis there 31,33,35,37,39

3 0
3 years ago
Other questions:
  • Audrey is saving for a school trip. She needs
    10·1 answer
  • Your friend is 1.2 times taller than you. Your friend is 64.5 inches tall. How tall are you?
    7·2 answers
  • Negative 5x equals negative 40
    15·1 answer
  • 1. Vincent spent 4/7 of his money on a pair of shoes. The shoes cost $48. How much money did he have at first?
    10·1 answer
  • Based on the following algebraic term, mark (/) for the correct coefficient and (x) for the incorrect coefficient.
    6·1 answer
  • I have two proof questions and I don't really know how to do them.
    12·1 answer
  • Y = 5x - 13<br><br> 4x + 3y = 18
    13·1 answer
  • For the differential equation y(n)+p1(t)y(n−1)+ ... +pn(t)y=0 with solutions y1, ..., yn Abel's formula for the Wronskian is W(y
    5·1 answer
  • Sara hina and Arslan have a total of RS 390in their wallet . Sara has Rs. 7more than Hina .Arslan has 3 times what sara has . Ho
    11·1 answer
  • Y+7=4/3(x+3) <br><br>A point on this line that is apparent from the given equation is?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!