You Are Browsing ‘Code’ Category

Generics : C# and .NET Interview Question – Lesson for beginners

Generics is one of the most important concept of object oriented programming. It exists not only in C# but is also used extensively in popular programming languages including Java. While Generics is an important concept which is often neglected, it remains to be one of the favorite question in C# and .NET interviews. One of our known was once working with TCS and on his very first viva during his training program,...

What are Various Types of Constants in C++ and their Use

We had given an introduction to constants when we had talked about the different types of tokens in C++. Now let us study constants in detail and see how they are used in C++ programs. First let us recall what constants are. DEFINITION : They are data items that do not change during a program. They are also called literals. So both the terms constants and literals are used interchangeably. TYPES OF CONSTANTS/LITERALS...

How to Declare and Initialize Variables in C++ – Tutorial for Beginners

In the previous post, we had seen what are the various built-in data types in C++. We are now ready to use them to create variables in our programs. First let us see what variables actually are and how they work. Definition : Variables are symbolic names given to memory locations that store various values. In other words, when we declare a variable and assign it any value, that value gets stored in memory at...

Registrations opened for Google Code Jam 2015 event

Google Code Jam is a renowned international programming/coding competition hosted officially by Google; Google Code Jam 2015 is now back with a bang. Registrations are still opened for the Google Code Jam 2015 event (started from March 10 and will end on April 12) and the qualification round will end on April 10. As it is an international event therefore finals will take place in Seattle, Washington (USA). Google...

Built-In Data Types in C++: char, int, float, double

Data types in C++ are keywords that are used to specify the type of the data we use in our C++ programs. There are many data-types available in C++. They are classified under two categories: Built-In or Fundamental Data types Derived or User-Defined Data types Built-in data types Built-in data types are the most basic data-types in C++. The term built-in means that they are pre-defined in C++ and can be used...

Use of endl and setw manipulators in C++

In the previous post, we had shown how basic input/output is performed in C++. Along with input/output operators, C++ provides a facility to control how the output is displayed on the screen. This is done using manipulators. Let us understand what manipulators are.  Manipulators are functions that are used to format or modify the output stream in various ways. They have a special characteristic that they are...

How to Perform Basic Input/Output Operations in C++

Input and Output operations are an important part of any program. Input operations take data from the user and output operations display the result of the program to the user. Let us understand the basic input/output operations in C++ program with the help of a simple program. The following program takes two numbers as input from the user, multiplies them and displays the result to the user. //Program to multiply...

Structure & Components of a basic C++ program – Tutorial for CBSE Class 11 & 12

Having learned about tokens in C++, we are now ready to write our first C++ program. The aim is to learn the basic structure and components of a C++ program. So what follows next is our program. It has been written and executed using the Dev C++ Compiler. //I am going to write my first C++ program /* The aim is to learn : 1) Structure of a program 2) Basic Components of a program */ #include<iostream> #include<conio.h> using...

Basics of While & Do-While Looping Constructs in C++

Loops are a very important part of any programming language. They provide the facility of iteration in our code. In other words, whenever we wish to execute a group of statements more than one time, loops come in handy. Both the while and do while loops execute a statement or a group of statements repeatedly if a particular condition is satisfied. So all you need is a condition to be evaluated and, of course,...