In C++:
Write a program that asks the user for an array of X numbers.
Your program moves the largest number all the way to the right, and then shows it to the user.
Hint: Use a loop to swap X times, but only swap if the number on the left is bigger than the number on the right.
Sample Run:
How many numbers would you like to enter? 6
Please enter number 1: 10
Please enter number 2: 8
Please enter number 3: 3
Please enter number 4: 5
Please enter number 5: 2
Please enter number 6: 9
The largest number is: 10
New List: 8, 3, 5, 2, 9, 10
#include <iostream>
using namespace std;
int main() {
int X, tmp;
cout<<"How many numbers would you like to enter? ";
cin>>X;
int* arr = new int(X);
for(int i = 0;i<X;i++){
cout<<"Please enter number "<<(i+1)<<": ";
cin>>arr[i];
}
for(int i = 0;i<X-1;i++){
if(arr[i] > arr[i+1]){
tmp = arr[i];
arr[i] = arr[i+1];
arr[i+1] = tmp;
}
}
cout<<"New List: ";
for(int i = 0;i<X;i++){
if(i==0){
cout<<arr[i];
}
else{
cout<<", "<<arr[i];
}
}
return 0;
}
In C++: Write a program that asks the user for an array of X numbers. Your...
(C programing, Not C++) Write a program in C that asks the user to input 10 numbers. Store these numbers in an array. Then ask the user to input a single number. Your program should execute a linear search on the array, trying to find that number. If the number exists in the array, have the program print out which position/element the number was found at. If the target number is not in the array, have the program print out...
In Small Basic Write a program that asks the user how many numbers s/he wishes to enter into an array and then enters a loop and proceeds to get those numbers from the user and enter them into the array. Once the array has been filled with the numbers, your program then asks the user to make a choice indicating what s/he wishes to do with the numbers in the array. The choices are: TextWindow.WriteLine("Enter 1 to compute and display...
Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...
write a program code that asks the user how many numbers they wish to find the statistics of and then asks the user to enter those numbers. The program must then calculate and display the average variance and standard deviation of the numbers entered by the user. the program code must -ask three user how many numbers they wish to find the statistics of -ask the user to enter those numbers and store them in an array - use a...
Write a C program that asks the user to enter two real numbers. Then your program displays a menu that asks the user to choose what arithmetic operation to be done on those numbers. Depending on the user's entry, the program should display the result to the screen. The sample runs below show what should be done to the numbers entered by the user. Your program should run exactly like shown in the sample runs. make your code run as...
Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in the array and then display the following data: The lowest number in the array The highest number in the array The total of the number in the array The average of the numbers in the array PLEASE GIVE THE PSEUDOCODE AND CODE IN C PROGRAMMING
Write a program that lets the user enter 10 values into an array. The program should then display the largest and the smallest values stored in the array. The program should display the following message to the user at the beginning "This program will ask you to enter ten values. Then it will determine the largest and smallest of the values you entered.Please enter 10 integers separated by spaces: " And then after user entered the numbers, it should display...
Write a program that asks the user to enter number, and displays all the numbers that are multiples of 2 and 5 smaller than or equal to the number entered by the user. Hint: A number n is a multiple of 2 if the remainder of the division of n by 2 is equal to zero. Your program should have an output similar to the following: Please enter a number: 50 The multiples of 2 and 5 less than or...
Write a program that asks a user to enter a number and the number of multiplications of that number to display Remember to use String.format() for this exercise. Enter a number: 2 Enter the multiplications: 10 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 =...
Using python Problem 6 (10 points). Write a program which asks the user to enter a number and prints its multiplication table upto 10. Sample program output: Please enter a number: 9 9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 9 X 10...