Respuesta :
I don't know which language you use those, so I assume that you use c++
for (int i = 1; i <= userNum; i++)
{
summedValue = summedValue + i;
i = i + 1;
}
for (int i = 1; i <= userNum; i++)
{
summedValue = summedValue + i;
i = i + 1;
}
def summedvalue( usernum):
oddcount = 0
for num in range (1, usernum + 1):
if (num % 2 != 0):
oddcount = oddtotal + num
print(oddcount)
sumvalue(10)
I will use python language to write the code.
def summedvalue( usernum):
oddcount = 0
for num in range (1, usernum + 1):
if (num % 2 != 0):
oddcount = oddtotal + num
print(oddcount)
sumvalue(10)
The code is written in python. def is a key word in python. It is use to declare a function in python. The function is named summedvalue. Then a variable is declared called oddcount. The variable is assigned an integer 0. The next line, we use a for loop to loop through the range 1 to the usernum(the user number is included). The next line we use the if statement to know if the looped numbers divided by 2 will have a remainder. If it has a remainder, then it is an odd number. The odd number will be added to the oddcount value(0) . The total value of the oddcount is printed out in the next line.
Finally, we call our function with the argument(usernum) . The user number(usernum) can be 1, 2, 3, 4, 5, 6, 7, 8, 9............
Note: pay attention to the indentation. Python uses indentation.
Read here for the JavaScript code :
https://brainly.com/question/5857734?referrer=searchResults