C++ Objects and Classes

Classes are used to create your own custom reusable data types which are called objects.  A class is a blueprint that defines the variables (data) and the methods (functions) common to all objects(members) of a certain kind. For example, let us consider a class called fruits. This class can have different objects called apple,mango,banana etc. They are instances of the... Continue Reading →

C++ Functions

A function is a set of statements that do a particular task or procedure.There are 2 types of functions: a)library functions b)user defined functions. Here, we talk about user defined functions. For example, a function to add 2 numbers may be defined in the C++ code. When this function is called, 2 numbers are added... Continue Reading →

C++ Iterative statements(cont.)

We have already seen for loops. Now let us look at while loop and the do-while loop. While loop A while loop enables you to execute a block of code if a given condition is true. It is like a repeating if statement. It checks the condition before each loop. The following code example shows how to... Continue Reading →

C++ Iterative statements

Iterative statements or repetitive statements or loops repeatedly execute a statement or multiple statements till a particular condition is met. Performing the same task repeatedly is called iteration. C++ provides us with 3 types of iterative statements namely for loop,while loop and do-while loop. You might need to iterate over a set of items in... Continue Reading →

C++ Decision making(cont.)

We have seen the use of if,if-else and if-else if-else loops for decision making.If there are too many else if statements the program becomes difficult and cumbersome. For this purpose we use the switch statement to replace multiple else if statements. The basic syntax of a switch statement is as follows: switch (a) ​{ case... Continue Reading →

C++ Decision making

Decision making requires that the programmer specifies one or more conditions to be evaluated by the program, along with: a statement or statements to be executed if the condition is determined to be true and other statements to be executed if the condition is determined to be false. The 2 main decision making statements in... Continue Reading →

C++ Operators

Operators are symbols that help us perform mathematical and logical operations on operands. Operators are used to perform operations on variables and constants.A list of C++ operators are given below. Prefix increment ++ Prefix decrement -- One's complement ~ Logical not ! Unary negation - Unary plus + Multiplication * Division / Modulus % Addition... Continue Reading →

C++ Enumerations

An enumeration is a user-defined type that consists of a set of named integer constants that are known as enumerators. Enum is a user defined data type where we specify a set of values for a variable and the variable can only take one out of a small set of possible values. We use enum keyword to... Continue Reading →

C++ Structures

We have gone through arrays in the previous blog. Let us recall the important points about an array. An array holds multiple values of the same data type in one variable. So the values must be of the same data type. What if you have values of different data types? What if you want to... Continue Reading →

Powered by

Up ↑