Answers for "Write a program in C++ that receives a series of integer values from the user."

C++
1

Write a program in C++ that receives a series of integer values from the user.

#include<iostream>

using namespace std;

int main()
{
    int c, n, nth;
    cout<<"Enter the number of values to enter: ";
    cin>>n;
    int arrayV[n];
    for(c=0;c<n;c++)
    {
        cout<<"Enter the value for array value "<<c<<": ";
        cin>>arrayV[c];
    }
    for(c=0;c<n;c++)
    {
        cout<<"\nValue "<<c<<" is "<<arrayV[c];
    }
    cout<<"\n\nEnter the index of the value you wish to remove: ";
    cin>>nth;
    if(nth>n)
    {
        cout<<"\n\nIndex out of range: ";
    }
    else
    {
        for(c=nth;c<=n-1;c++)
        {
            arrayV[c]=arrayV[c+1];
        }
        for(c=0;c<n-1;c++)
        {
            cout<<"\nValue "<<c<<" is "<<arrayV[c];
        }
    }
    return 0;
 }
Posted by: Guest on August-23-2021

Code answers related to "Write a program in C++ that receives a series of integer values from the user."

Browse Popular Code Answers by Language