#include#include using namespace std; int main() { vector v; // Creating a vector v.push_back(10); // Adding elements to the vector v.push_back(20); v.push_back(30); for (int i = 0; i < v.size(); i++) { // Looping through the elements cout << v[i] << " "; } return 0; }
#includeThis code creates a window with a square polygon drawn inside it using OpenGL. The display function has been implemented and called inside the main function, and the window is created using glutCreateWindow (which is part of the OpenGL Utility Toolkit (GLUT) package). The OpenGL package is also used with headers#include #include void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutCreateWindow("OpenGL Window"); glutDisplayFunc(display); glutMainLoop(); return 0; }