Trying to ask a user to provide a set of numbers, then have program determine if the numbers are in ascending order or n
By : user2445325
Date : March 29 2020, 07:55 AM
hop of those help? I am trying to create a program that asks the user for a set of numbers, first asking for the quantity of numbers, then having them input all the numbers. The program then checks the numbers, and determines whether or not the numbers given are in ascending order or not. Then, simply print out "yes ascending" or "no not ascending" and print out the array on one line..So far, my code will just always say that "yes, this is an increasing array!" Please look below for my code. in advance!.. , You're reading in "numbers", which you created as type String. code :
cout << "Enter the numbers in the array, separated by a space, and press enter: " << endl;
numbers += ' ' + numbers;
cin >> numbers;
int arr[arraysize];
if ( isAscending(arr, arraysize)){....}
int main(){
int arraysize = 0;
int number = 0;
cout << "Enter the size of the array: " << endl;
cin >> arraysize;
if (arraysize < 1) // you should really have this loop until you get correct input
{ cout << "ERROR: you entered an incorrect value for the array size!" << endl; }
int* arr = new int[arraysize];
cout << "Enter the numbers in the array, separated by a space, and press enter: " << endl;
int i = 0;
while(i < arraysize){
cin >> number;
arr[i] = number;
i++;
};
if ( isAscending(arr, arraysize)){ cout << "This IS an increasing array!" << endl; }
else{ cout << "This is NOT an ascending array!" << endl;}
for (int i = 0; i < arraysize; i++){
cout << arr[i];
if( (i+1) == arraysize){ cout << ". ";}
else cout << ", ";
}
return 0;
}

Finding Sum of Prime Numbers between interval (C++ program doesn't work for large numbers)
By : HarisKhalid
Date : March 29 2020, 07:55 AM
To fix this issue The problem you are dealing with is integer overflow. (signed) long can on most machines have values between 2147483647 and 2147483647.

program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by one
By : WangYue
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Your logic in the "processing" block seemed off. I modified it to check the current number (outer loop) to all of the known numbers (inner loop). If no match was found, it is appended to the list of known numbers and the count is incremented. I also modified the "output" code to print the first counter numbers from the list of known numbers. Values past that index are uninitialized. code :
import java.util.Scanner;
public class problem2try {
public static void main(String[] args) {
//declarations
Scanner keyboard = new Scanner (System.in);
int [] inputList = new int [10];
int [] distinctArray = new int [10];
int num;
int counter = 0;
//input
System.out.print("Please enter in 10 integers: ");
for (int i = 0; i < inputList.length; i++)
{
num = keyboard.nextInt();
inputList[i] = num;
}
//processing
for (int i = 0; i < inputList.length; i++)
{
boolean found = false;
for (int j = 0; j < counter; j++)
{
if (inputList[i] == distinctArray[j])
{
found = true;
break;
}
}
if (!found)
{
distinctArray[counter++] = inputList[i];
}
}
//output
System.out.println("The number of distinct numbers is " + counter);
System.out.print("The distict numbers are: ");
for (int x=0; x<counter; x++)
{
System.out.print(distinctArray[x] + " ");
}
}
}

C++ Program to Display Numbers Between Two Intervals Check Whether a Number can be Express as Sum of Two Prime Numbers
By : Alex
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You have to reset your flag at each loop otherwise once it's set with true value, this condition will never be reached if (flag == false). code :
for (i = n1 ; i <= n2 ; i++)
{
flag = false; /* Reset the flag */
for (j = 2 ; j <= i/2 ; j++ )
{
if(checkPrime (j) && checkPrime (ij))
{
cout << "Number " << i << " equal sum of two prime number " << j << " + " << i  j << endl;
flag = true;
}
}
if (flag == false)
{
cout << "Number " << i << " can't epress to sum of two prime number " << endl;
}
}

I am trying to create a program that averages numbers, but cannot figure out how to add the user inputted numbers togeth
By : Deepali Suryawanshi
Date : March 29 2020, 07:55 AM

