Question

2.) Write a program that will prompt the use to enter 10 numbers in an array, then display: the 1st, the 5th and the last numUSE C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution 2:-

C++ code:-

#include <iostream>
using namespace std;
// main function
int main()
{ // Declaring array
int arr[80];
// Looping till the end of the array
for(int i=1;i<11;i++)
{ // Prompt the user to enter numbers
cin>>arr[i];
}
// Printing the first number
cout<<"1st is "<<arr[1]<<endl;
// Printing the fifth number
cout<<"5th is "<<arr[5]<<endl;
// Printing the last number
cout<<"last is "<<arr[10];
return 0;
}

Code snapshot:-

#include <iostream> using namespace std; // main function int main() { // Declaring array int arr[80]; // Looping till the en

Output snapshot:-

1 2 3 4 5 6 7 8 9 10 1st is 1 5th is 5 last is 10

Add a comment
Know the answer?
Add Answer to:
USE C++ 2.) Write a program that will prompt the use to enter 10 numbers in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • USE C++ 3. Write a program that will prompt the us to enter 5 numbers in...

    USE C++ 3. Write a program that will prompt the us to enter 5 numbers in an array, The progra shall be able to change all inputs w negative values with zero. Example, If the user entered: 1,-2,3,4,-6 The output shall be: 1,0,3,4,0. Replacing negative inputs with zero. [points:10]

  • Write a complete program in assembly line that:    1. Prompt the user to enter 10...

    Write a complete program in assembly line that:    1. Prompt the user to enter 10 numbers.    2. save those numbers in a 32-bit integer array.    3. Print the array with the same order it was entered.    3. Calculate the sum of the numbers and display it.    4. Calculate the mean of the array and display it.    5. Rotate the members in the array forward one position for        9 times. so the last...

  • Write a program in Java language to prompt the user to enter 3 integers (A, B,...

    Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...

  • 1. print mesage to user to prompt user to enter 10 numbers 2 have program accept...

    1. print mesage to user to prompt user to enter 10 numbers 2 have program accept 10 numbers from user and populate 10 occurrances of an array (use a loop to do this). 3. print message to user to advise user contents of array follows 4. have program display array contents (use loop to do this) end program comment in java please

  • You are hired by a college to write a Java program to use a so-called check...

    You are hired by a college to write a Java program to use a so-called check sum technique for catching typing errors of student ID. The college assigns a seven-digit number to each student. The seventh digit (i.e., the rightmost digit) is determined from the other digits with the use of the following formula: 7th digit = (1 *(1st digit) * 2 * (2nd digit) * ... * 6 * (6th digit)) % 10 Your program should prompt users to...

  • need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that...

    need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...

  • (C programing, Not C++) Write a program in C that asks the user to input 10...

    (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...

  • 1. Write a program that reads in two arrays (a1 and a2) of numbers and creates...

    1. Write a program that reads in two arrays (a1 and a2) of numbers and creates a new array (a3) of numbers such that the new array contains all the unique numbers of a1 and a2. Assume the input array elements are unique elements. In the main function, ask the user to enter the length of each array, declare and reads in the numbers for each array, and calculate and display the output array. Example input/output #1: Enter the length...

  • Write a C++ program that simulates a lottery game. Your program should use functions and arrays....

    Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...

  • Write a complete program that: 1. Promts the user to enter 10 numbers. 2. saves those...

    Write a complete program that: 1. Promts the user to enter 10 numbers. 2. saves those numbers in a 32 bit integer array. 3. Calculates the sum of the numbers and displays it. 4. Calcualtes the mean of the array and displays it. 5. Prints the array with the same order it was enterd. 6. Rotates the members in the array forward one position for 9 times. so the last rotation will display the array in reversed order. Print the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT