🔒 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
934
Guests online
2,898
Total visitors
3,832

Forum statistics

Threads
2,294,142
Posts
29,089,000
Members
1,208,097
Latest member
styg
Back
Top