🔒 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
1,054
Guests online
5,063
Total visitors
6,117

Forum statistics

Threads
2,354,415
Posts
29,383,599
Members
1,079,449
Latest member
Iaa
Back
Top