Question

(Write in C++)

Write a program that reads in two numbers and, if the input is valid, outputs 2 times the product of the integers that lie between the two values (including the values themselves). If either number is not an integer, or if the first number is not less than the second number, just output an error message. The sample runs below should give the idea. User inputs are in bold. Important Notes: Your program should use a loop to calculate the sum, i.e. you will lose marks if you use a formula to calculate the product. It should just deal with just one set of inputs and stop.

First example (the output is twice the product of
5*6*7* 8 *9*10):

Enter two integers (smaller number first): 5 10

Twice the product of the integers in between

these values is: 302400

Second example (the first number is not less than the
second number):

Enter two positive integers (smaller number first): 10 6

You did not follow the instructions!

Third example (one or both values are not
integers):

Enter two positive integers (smaller number first): 6.5 10

You did not follow the instructions!

l want solve neccessary please

Answer #1

C++ program

- Find the twice of product integer between the input.
- Validate the input first integer is < second integer
- Validate the input as an integer.

Source code:

```
//C++ Program
//Sum of Natural Numbers in a given range
#include<iostream>
using namespace std;
//main Program
int main()
{
int mul = 1, upper_limit, lower_limit;
cout << "Enter two positive integers:\n";
cin >> lower_limit;
cin >> upper_limit;
if(upper_limit>lower_limit){
//calculating product of numbers in the given range
for(int i = lower_limit; i <= upper_limit; i++)
mul *= i;
//printing output
cout<<"Twice the product of integers between "
<< lower_limit << " to " << upper_limit << " is:\n" << mul*2;
}
else{
cout<<"You did not follow the instuction\n";
}
return 0;
}
```

**The output**

(C++) 5.15 LAB: Two smallest numbers with arrays
Write a program that reads a list of integers, and outputs the
two smallest integers in the list, in ascending order. The input
begins with an integer indicating the number of integers that
follow.
Ex: If the input is:
5 10 5 3 21 2
the output is:
2 3
You can assume that the list of integers will have at least 2
values.
To achieve the above, first read the integers...

C++
INSTRUCTIONS Problem Specification
: Write a program that reads a group of numbers from the user
and places them in an array of type float. Once the numbers are
stored in the array, the program should average and print the
result. Use pointer notation wherever possible.
Program Output (with Input Shown in Bold):
Enter number: 2 Enter another (y/n)? y
Enter number: 4 Enter another (y/n)? y
Enter number: 6 Enter another (y/n)? y
Enter number: 8 Enter another...

Write a complete Java program to solve the following
problem.
Read two positive integers from the user and print all the
multiple of five in between them. You can assume
the second number is bigger than the first.
For example if the first number is 1 and the second number is
10, then your program should output
5 10
Note: There is a white space in between the numbers.
Java programming
please answer ASAP before 2:30

Java Program : Please save the program with the name
‘Dstring.java’
Write a program that reads a string from the keyboard. If the
length of the string is an even number, your program should split
the string into two strings of equal length. If the length of the
string is odd, your program should split the string into two
strings where the first part has one more character than the second
part. Your program should output the two strings it...

IN C LANGUAGE
This program initially reads two integers from standard input:
(1) an integer T and (2) a positive integer N. It then reads N
integers and counts the numbers that are greater than T and the
numbers than are less than T. It then prints out these two
counts.
Example
What is the threshold value?
7
How many values?
5
Enter 5 values:
6 7 9 9 8
3 values are greater than 7
1 values are less...

Draw a flowchart for a computer program to receive 40 numbers
and output “yes” if number of negative values among the first 10
inputs is equal to number of positive values among the last 10
inputs. Note. The 20 numbers in middle are ignored. For instance,
if the values are:
1,-1,1,1,-1,1,-2,5,1,1,4,4,5,-6,5,8,-12,0,2,0,1,2,3,7,7,-7,0,1,1,1,3,4,1,-1,-1,-1,-1,-1,-1,-1
the program should output “yes” since the number of negative values
in the first 10 numbers is 3, and the number of positive values in
the last 10 numbers...

In Coral,write a program that reads a list of 10
integers and outputs those Integers in Reverse. For coding
Simplicity, follow each output integer by a space, including the
last one. Then, output a new line. Example if the input is 2 4 6 8
10 12 14 16 18 20, the output is: 20 18 16 14 12 10 8 6 4 2 to
achieve above first read the integers into an array. Then output
the array in reverse

Write a program to ask user to input
an integer and display the special pattern accordingly.
REQUIREMENTS
The user input is always correct (input verification is not
required).
Your code must use loop statements (for, while or
do-while).
Your program should use only the following 3
output statements, one of EACH of the
followings:
System.out.print("-"); // print #
System.out.print("+"); // print +
System.out.println(); // print a newline
Your code must work exactly like the following example (the
text in bold...

Write a C++ program that reads two integers from the user. The
program should
tell whether the two numbers are equal or not.

In Java. Write a program that reads-in a times
table-number. The program, using this
table-number will produce the following report (as
shown). The first item in the report is a number
with starting value 1. Second column is the word “ X ”
(representing the times symbol). Third column is the
table-number (itself). Following is an equal sign
“ = “ (representing a result). Last column is the
result of the operation for that line or row which
is the...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 39 minutes ago

asked 42 minutes ago

asked 56 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago