answersLogoWhite

0


Best Answer

Accept 5 numbers in an array and display it.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Accept 5 numbers in an array and display it?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Program that display the first 5 odd numbers?

printf("1 3 5 7 9\n");


How do you create Write a program that takes 10 integers as input The program will place these integers into an array and display the following 1. List in ascending order 2. mean 3. median 4.max val?

import java.util.Arrays; import java.util.Scanner; public class Answers { public static void main(String[] args) { //Creates a scanner object named console. Scanner console = new Scanner(System.in); //Variabels int [] numbers = new int [10]; double avg = 0.0; double median = 0.0; int max = numbers[0]; double count = 0.0; //User input. for (int i = 0; i < numbers.length; i++){ System.out.print("Number: "); numbers[i] = console.nextInt(); } //break System.out.println("==============="); //finds the average and max value. for (int i = 0; i < numbers.length; i++){ count += numbers[i]; avg = count / numbers.length; //average if (numbers[i] > max){ //finds the max value. max = numbers[i]; } } median = (numbers[4] + numbers[5])/2; //Median value //Display to user. System.out.println("Highest value found: " + max); //Show maximum value found in array System.out.printf("Median is: %.3f \n",median); //Show median System.out.printf("Average is: %.3f \n",avg); //Show average sortAsc(numbers); //Print out whole array ascending } //Method for sorting an Array ascending. public static void sortAsc(int [] array){ for (int i = 0; i < array.length; i++){ Arrays.sort(array); System.out.println(array[i]); } } } This should do everything you asked for, hope this helps!


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i < 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }


What is array What is difference between array and simple variable?

An array stores several values - for example, several numbers - using a single variable name. The programmer can access the individual values with a subscript, for example, myArray[0], myArray[5]. The subscript can also be a variable, for example, myArray[i], making it easy to write a loop that processes all the elements of an array, or some of them, one after another.


Which element of array does this expression refer num5?

which element of the array does this expression reference num[5]

Related questions

Which numbers have a square array?

5


What is a 5 x 5 matrix?

An array consisting of 5 rows and 5 columns of numbers (or variables).


How do you print a number as on or more literal words in PHP?

Create an array like so $numbers = array(); $numbers['0'] = "ZERO"; $numbers['1'] = "ONE"; and so on.. till you decide that's enough then to print it, echo the array with the desired key like so.. Example I print 5 in words echo $numbers['5']; which would print FIVE Good luck


How do you make a C plus plus program that arrange the the numbers in ascending order?

Heres something i whipped up in a hurry... This uses the Bubble Sort method found (related links) #include <iostream> using namespace std; int main(int argc, const char* argv) { int arraysize = 5; //Unsorted array size int array [] = { 5, 3, 4, 2, 1 }; //The array of numbers itself //Display the unsorted array cout << "Before: {"; for (int c=0; c <= arraysize; c++) { cout << array[c]; if (c != arraysize) { cout << ","; } } cout << "}" << endl; //Acctually sort the array int tmp=0; //Used for swaping values for (int loop=0; loop <= (arraysize - 1); loop++) { for (int c=0; c <= (arraysize - 1); c++) //The sort loop { if (array[c] > array[c + 1]) { //Swaps the two values in the array tmp = array[c]; array[c] = array[c + 1]; array[c + 1] = tmp; //Cleanup tmp = 0; } } } //Display the sorted array cout << "After: {"; for (int c=0; c <= arraysize; c++) { cout << array[c]; if (c != arraysize) { cout << ","; } } cout << "}" << endl; return 0; }


How do you write an array that computes the product of the two numbers in java?

You don't need an array for that. Just do the multiplication, for example: result = factor1 * factor2; Or: result = 5 * 8;


Program that display the first 5 odd numbers?

printf("1 3 5 7 9\n");


What is the smallest LED matrix required to display numbers 0-9?

It can be done with 7 LED segments. More LEDs will be needed if a regular rectangular array is required, but many of these will never light and could be omitted to save money but then it would not be regular. The smallest standard regular rectangular array sold is 5 by 7 or 35 total LEDs, but this will display all alphanumeric characters and even then some LEDs will be unused unless other things are displayed too. Just guessing the smallest regular array is probably 3 by 5 or 15 total LEDs, but at most 13 of these LEDs would be used by the digits the other 2 LEDs could be omitted to save money. Such an array could be wired to be driven as a 7 segment display using a few ordinary diodes to light the 6 shared LEDs as part of multiple "segments".


How do you create Write a program that takes 10 integers as input The program will place these integers into an array and display the following 1. List in ascending order 2. mean 3. median 4.max val?

import java.util.Arrays; import java.util.Scanner; public class Answers { public static void main(String[] args) { //Creates a scanner object named console. Scanner console = new Scanner(System.in); //Variabels int [] numbers = new int [10]; double avg = 0.0; double median = 0.0; int max = numbers[0]; double count = 0.0; //User input. for (int i = 0; i < numbers.length; i++){ System.out.print("Number: "); numbers[i] = console.nextInt(); } //break System.out.println("==============="); //finds the average and max value. for (int i = 0; i < numbers.length; i++){ count += numbers[i]; avg = count / numbers.length; //average if (numbers[i] > max){ //finds the max value. max = numbers[i]; } } median = (numbers[4] + numbers[5])/2; //Median value //Display to user. System.out.println("Highest value found: " + max); //Show maximum value found in array System.out.printf("Median is: %.3f \n",median); //Show median System.out.printf("Average is: %.3f \n",avg); //Show average sortAsc(numbers); //Print out whole array ascending } //Method for sorting an Array ascending. public static void sortAsc(int [] array){ for (int i = 0; i < array.length; i++){ Arrays.sort(array); System.out.println(array[i]); } } } This should do everything you asked for, hope this helps!


A grocery manager wants to display 45 cans of peas in an array. How many different ways can he display the cans?

A lot more,.....45,1. 5,9. 15,3. So basically 3 dude


Write C program for Accept temperature in degree Celsius and display the same in Fahrenheit?

The variable, X, has to undergo the following: X*9÷5+32 [The reverse would be to accept a Fahrenheit temperature: (F-32)*5÷9]


Simple c programs for practice?

Accept a number. Display all numbers from 0 up to it. Example: If input number is 5, output should be 0 1 2 3 4Accept two numbers. Display all numbers between them. Example: If input numbers are 10 and 15, output should be 11 12 13 14Accept a number. Display all even numbers less than that number. Example: If input number is 7, output should be 2 4 6Accept a number and display its multiplication table. Example: If input number is 3, output should be 3 X 1 = 3, 3 X 2 = 6..... [For/while loop needed]Accept a number and find the sum of all numbers from 0 till that number. If input number is 3, output should be 6 (0 + 1 + 2 + 3)Create two int variables a and b, each = 30000. Try to assign c = a +b. Display c. Answer is not 60000. Why?Good luck.


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i < 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }