USING C Load 10 integers into an array then prompt the user

USING C++

Load 10 integers into an array, then prompt the user for a number from 0 to 9. Display the element at the array position the user selects. For example:

It should output exactly like this:

Solution

#include<iostream>
using namespace std;
int main()
{

int a[10],num,i;

cout<<\"Enter the array elements\";
//entering the array elements
for(i=0;i<10;i++)
{
cin>>a[i];
}

//entering the number between 0 to 9
cout<<\"Enter a number from 0 to 9\";
cin>>num;
//displaying the number at the position specified by user
cout<<\"Element number \"<<num<<\" is \"<<a[num];
return 0;
}

USING C++ Load 10 integers into an array, then prompt the user for a number from 0 to 9. Display the element at the array position the user selects. For example

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site