Author: saqibkhan
-
Variable Scope in C++
A scope is a region of the program and broadly speaking there are three places, where variables can be declared − C++ variables scopes are categorized mainly two parts − We will learn what is a function and it’s parameter in subsequent chapters. Here let us explain what are local and global variables. Local Variables…
-
Variables and Types
C++ Variable A variable provides us with named storage that our programs can manipulate. Each variable in C++ has a specific type, which determines the size and layout of the variable’s memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.…
-
Character (char) Data Type
The character (char) data type in C++ stands for alphanumeric values, which can be a wide range of characters. These may include alphabets like ‘a’, ‘b’, and ‘c’, numeric values like ‘1’, ‘2’, and ‘3’, symbols like ‘#’, ‘$’, and ‘&’, and many more. The character data type takes 1 Byte (i.e., 8 bits) of memory space to store…
-
Boolean (bool) Data Type
The bool data type in C++ stands for Boolean values, which are True and False. In C++, 1 stands for True whereas 0 stands for False. The keyword “bool” is used to declare a Boolean data type. The addition of bool data type is a one of the newer features of C++ language. Use of Boolean Data Type The Boolean (bool) data type is used in the following ways…
-
Numeric Data Types
Numeric data types in C++ are used to handle numerical data like integers (both signed and unsigned), floating-point values, and precision values. Numeric data types mainly contain three fundamental types of numeric data, which are as follows − In this article, we will go through all of the numeric data types and their subtypes in…
-
Omitting Namespace in C++
Omitting Namespace You can explicitly use the std:: prefix for standard library objects and functions instead of using the “using namespace std“. Example of Omitting Namespace Here’s a simple example to illustrate this − In this example we had directly used std::string and std::count instead of using using namespace std; When and Why to Omit Namespaces? Omitting namespaces in C++ can be…
-
“Hello, World!” Program
Printing “Hello, World!” is the first program in C++. Here, this prints “Hello, World” on the console (output screen). To start learning C++, it is the first step to print sometime on the screen. C++ Program to Print “Hello, World!” Let us see the first C++ program that prints “Hello, World!” − Open Compiler Output This program will print…
-
Data Types
While writing program in any language, you need to use various variables to store various information. Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. You may like to store information of various data types like character, wide character, integer, floating point,…
-
Comments
C++ Comments Program comments are explanatory statements that you can include in the C++ code. These comments help anyone reading the source code. All programming languages allow for some form of comments. Types of C++ Comments C++ supports two types of comments: single-line comments and multi-line comments. All characters available inside any comment are ignored by the C++ compiler.…
-
Basic Syntax
When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other’s methods. Let us now briefly look into what a class, object, methods, and instant variables mean. C++ Program Structure The basic structure of a C++ program consists of the following parts: To learn more…