Answers for "how to take unknown no of input in cpp"

C++
0

how to take unknown no of input in cpp

#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int x;
    vector<int> v;
    while(cin>>x)
    {
        v.push_back(x);
    }
    for (int i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    return 0;
}
Posted by: Guest on January-22-2021

Code answers related to "how to take unknown no of input in cpp"

Browse Popular Code Answers by Language