Data Structures

Explain Stack

It is a linear data structure or ordered collection of elements where the elements are processed in last in first out manner(LIFO). In stack insertion and deletions are made at one end i.e top Stack can be implemented by using array or linked list Operations on stacks. Special terminology is used for two basic operations […]

C and C++

Explain Constructors

Constructors are special class functions which performs initialization of every object. The Compiler calls the Constructor whenever an object is created. Constructor’s initialize values to data members after storage is allocated to the object. While defining a constructor you must remember that the name of constructor will be same as the name of the class, […]

C and C++

Explain Namespace

Namespace is a new concept introduced by the ANSI C++ standards committee. A namespace is introduced to avoid name clashes (global name conflicts) like re-declaration of variables, method names, class, and structure names. Syntax for using standard namespace: using namespace std; In the above syntax “std” is the namespace where ANSI C++ standard class libraries […]

C and C++

Explain function overloading with example

Function overloading means, two or more functions have the same names but different argument lists The arguments may differ in the type of arguments or number of arguments, or both. However, the return types of overloaded methods can be the same or different is called function overloading. Function overloading concepts helps us to use the […]

C and C++

C++ program to swap two integers values and display the values before and after swapping using call by reference

#include<iostream> using namespace std; void swap(int &x, int &y) { int temp; temp = x; x = y; y = temp; } int main() { int a, b; cout<<“Enter the value of a: “; cin>>a; cout<<“Enter the value of b: “; cin>>b; cout<<endl<<“Before swapping: “; cout<<“a= “<<a<<” and b= “<<b; swap(a, b); cout<<endl<<“After swapping: “; […]

C and C++

Explain reference variable

A reference variable is just another name to an already existing variable. Creating Reference Variable The reference variable is created using the & symbol. For example, let a is a variable and we can create a reference variable of a as x as follows, int a =10; int &x=a; Here variable x is a reference […]

C and C++

List & explain Basic features of object oriented programming language

Basic concepts and features of object oriented programming language like C++. Following are the features or basic concepts of C++ programming language. 1. Objects and Classes 2. Data abstraction 3. Data encapsulation 4. Inheritance 5. Polymorphism 6. Binding 7. Message passing 1. Objects and Classes: Classes are user-defined data types on which objects are created. […]

C and C++

Difference between Procedure Oriented Programming and Object Oriented Programming

Procedure oriented programming Object oriented Programming Emphasis is given more to procedures (functions) Emphasis is given more to data in OOP The programming task is divided into a collection of data structures and methods or functions. The programming task is divided into objects (consisting of data members and associated member functions) Procedures are being separated […]

Computer Graphics

Display Window Management Using GLUT

We can consider a simplified example, minimal number of operations for displaying a picture. Step 1: initialization of GLUT We are using the OpenGL Utility Toolkit, our first step is to initialize GLUT. This initialization function could also process any command line arguments, but we will not need to use these parameters for our first […]