I have answered the question below.
Code:
Sub program()
Dim firstNum, secondNum, i, n As Integer
firstNum = InputBox("Enter firstNum: ")
secondNum = InputBox("Enter secondNum: ")
If firstNum < secondNum Then
n = secondNum - firstNum - 1
Dim odd_sum, even_sum As Integer
odd_sum = 0
even_sum = 0
For i = firstNum + 1 To secondNum - 1
If i Mod 2 = 0 Then
msg1 = msg1 & i & vbTab
even_sum = even_sum + i
Else
msg2 = msg2 & i & vbTab
odd_sum = odd_sum + i
End If
Next i
MsgBox "Even Numbers between " & firstNum & " and " &
secondNum & ":" & vbTab & msg1 & vbNewLine
MsgBox "Sum of Even numbers: " & even_sum & vbNewLine
MsgBox "Odd Numbers between " & firstNum & " and " &
secondNum & ":" & vbTab & msg2
MsgBox "Sum of Odd numbers: " & odd_sum & vbNewLine
Else
MsgBox "firstNum should be less than secondNum"
End If
End Sub
Snapshot of the code with explanation in comments:
Sample Output:
If you have any doubts feel free to ask me in comments,
Thank you, Have a nice day..!!
write the program in VBA b. Write a program that uses a For loop to perform...
I have to write a program in java which uses while loops. 1.prompt the user to input two intergers: firstnum ans second numnumber. (first number must be smaller that the second number). 2. Output all the even numbers between first number and second number inclusive. 3. Output the sum of all the even number between first number and second number inclusive. 4 Output all the odd numbers between first number and second number inclusive. 5. Output the sum of all...
Use a java program that does the following: . (10 points) Write a program as follows a. Prompt the user to input two positive integers: nl and n2 (nl should be less than n2) b. If the user enters the negative number(s), convert it/them to positive number(s) c. If nl is greater than n2, swap them. d. Use a while loop to output all the even numbers between nl and n2 e. Use a while loop to output the sum...
Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 25.
Write a Python named numbersread.py that uses a loop to read and process numbers.txt. The program should output all of the integers, one per line, and then output the total of the even integers and the total of the odd integers.
Write a C++ program that asks the user to enter a single number from 1 to 50 and a choice of "even" or "odd". Using a recursive function, output the sum of all the even or odd integers from 1 up to (and including) that number. Your program does not need to loop and accept more input (only one input of the number then even/odd).
1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...
python la ab X, X Lab 7 Design and implement a Python program that uses a while loop and selection statements to print the sum of the even numbers and the sum of the odd numbers (all integers) read from the keyboard. The sequence of numbers ends with a negative number: So, all numbers considered for printing the two sums are greater than or equal to 0. The sequence may be empty. Here is a possible interaction. Enter an integer:...
Write a VBA Sub Program to perform matrices multiplication of matrix A and B using 2D arrays. a. Get the number of rows and columns of both matrix A and B from the user, and check if multiplication is possible with matrix A and B. b. If matrices multiplication is possible, input the matrix A and B using arrays and multiply matrix A and B.
Q1. Write a program in Java a. Create 2 separate arrays, of user defined values, of same size b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....
Write a program that will loop ten times. In each iteration prompt user to enter an integer between -50&50. Print the input, keep a running sum of the inputs, and track the minimun and maximum numbers input. After the loop is complete, minimum number entered, maximum number entered, sum of all numberes entered, and average of all numbers entered. Format all output. Before running the loop, print the label "Input values: ". Within the loop, print value entered by user...