Pages

Saturday, April 26, 2025

Vectors in C++

 #include <iostream>

#include <vector>

using namespace std;


int main()

{

    vector<int> vec1(10, -1);

    cout << vec1.size() << "\n";

    

    

    // to access size of invidivual vectors

    

    for(int i=0; i<vec1.size(); i++) {

        cout << vec1[i] << " ";

    }

    

    cout << endl;

    return 0;

}

No comments:

Post a Comment

Stack using Linked List – Partial (University Exam Topic)

 #include <iostream> using namespace std; struct Node {     int data;     Node* next; }; class Stack {     Node* top; public:     Stac...