🔒 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

Trending Topics

Online now

Members online
366
Guests online
3,400
Total visitors
3,766

Forum statistics

Threads
2,331,971
Posts
29,261,465
Members
1,147,943
Latest member
Jrob30
Back
Top