🔒 Closed array

Status
Not open for further replies.
dito ako naguguluhan pano ko idedec;are ung aray na walang laman ganon lang pala ung variable a diniclare tapos gumawa ka ng panibagong variable na numbers kung saan ayun ung naging lalagyan ng iinput ng user,, hahhha yun lang pala dami kung pinuntahan haha di ako familliar sa array kasi
 
What you need is a vector of int.

Code:
#include <iostream>
#include <vector>

int main (int argc, char* argv[]) {
    int mysize {0};
    std::cout << "Enter size of vector: ";
    std::cin >> mysize;
    std::vector<int> myvector;
    for (int i=0; i<mysize; i++) {
        int n{0};
        std::cout << "Enter num: ";
        std::cin >> n;
        myvector.push_back(n);
    }
    for (int x : myvector) {
        std::cout << x << std::endl;
    }
    return 0;
}
 
Status
Not open for further replies.

About this Thread

  • 33
    Replies
  • 1K
    Views
  • 8
    Participants
Last reply from:
GHOZT05

Online now

Members online
265
Guests online
662
Total visitors
927

Forum statistics

Threads
2,276,506
Posts
28,970,475
Members
1,231,330
Latest member
ihebayari
Back
Top