Difference Between Constant and Variable in C++

Samual Sam
Updated on 11-Feb-2020 08:10:33

2K+ Views

Variable and constant are two commonly used mathematical concepts. Simply put, a variable is a value that is changing or that have the ability to change. A constant is a value which remains unchanged.For example, if you have a program that has a list of 10 radii and you want to calculate the area for all of these circles. To find the area of these circles, you'll write a program that will have a variable that will store the value of PI and this value will not change throughout the program. Such values can be declared as a constant.In the ... Read More

Different Types of Constants in C++

Lakshmi Srinivas
Updated on 11-Feb-2020 08:09:49

816 Views

There are no types of constants in C++. It's just that you can declare any data type in C++ to be a constant. If a variable is declared as constant using the const keyword, you cannot reassign its value. Example#include using namespace std; int main() {    const int i = 5;    // Now all of these operations are illegal and    // will cause an error:    i = 10;    i *= 2;    i++;    i--;    //...    return 0; }

Define Constants in C++

Arushi
Updated on 11-Feb-2020 08:08:30

746 Views

You can define constants in C++ by adding the const qualifier before the declaration of the variable. Example#include using namespace std; int main() {    const int x = 9;    x = 0;    return 0; }This will define the constant variable x. But it will throw an error as we are trying to rewrite the value of a constant.

Call Interface Method in Java

raja
Updated on 11-Feb-2020 08:06:59

22K+ Views

In order to call an interface method from a java program, the program must instantiate the interface implementation program. A method can then be called using the implementation object.Examplepublic interface InterfaceDemo{     default public void displayNameDefault(String name){        System.out.println("Your name is : " + name);    }     public void displayName(String name);     public void displayNameAndDesignation(String name, String designation); }The above interface defines three methods for displaying a name and optionally a job title. One method is a default method that contains implementation logic. The remaining two methods do not include implementation logic.public class InterfaceDemoImpl ... Read More

Rules to Declare Variables in C++

Sharon Christine
Updated on 11-Feb-2020 08:06:43

12K+ Views

To declare a variable, you need to know what data type it is going to be of and what its name would be. The variable name has constraints on what you can name it. Following are the rules for naming variables − Variable names in C++ can range from 1 to 255 characters. All variable names must begin with a letter of the alphabet or an underscore(_). After the first initial letter, variable names can also contain letters and numbers.   Variable names are case sensitive. No spaces or special characters are allowed. You cannot use a C++ keyword (a reserved word) as a variable name.Here ... Read More

Basic Rules for Defining Variables in C++

Arjun Thakur
Updated on 11-Feb-2020 08:04:48

1K+ Views

To declare a variable, you need to know what data type it is going to be of and what its name would be. The variable name has constraints on what you can name it. Following are the rules for naming variables −Variable names in C++ can range from 1 to 255 characters.All variable names must begin with a letter of the alphabet or an underscore(_).After the first initial letter, variable names can also contain letters and numbers.  Variable names are case sensitive.No spaces or special characters are allowed.You cannot use a C++ keyword (reserved word) as a variable name.Here are ... Read More

What is Type Inference in C++

Samual Sam
Updated on 11-Feb-2020 08:02:36

790 Views

Type inference or deduction refers to the automatic detection of the data type of an expression in a programming language. It is a feature present in some strongly statically typed languages. In C++, the auto keyword(added in C++ 11) is used for automatic type deduction. For example, you want to create an iterator to iterate over a vector, you can simply use auto for that purpose. Example#include #include using namespace std; int main() {    vector arr(10);    for(auto it = arr.begin(); it != arr.end(); it ++) {       cin >> *it;    }    return 0; }In the ... Read More

Declare a Variable in C++

Monica Mona
Updated on 11-Feb-2020 08:01:15

615 Views

In C++, declaration and definition are often confused. A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in memory for any variable in case of a declaration.The Definition on the other hand means that in additions to all the things that declaration does, space is additionally reserved in memory. You can say "DEFINITION = DECLARATION + SPACE RESERVATION".Following are examples of declarations −extern int a;       ... Read More

Main Features and Enhancements Introduced in Java 9

raja
Updated on 11-Feb-2020 08:00:28

267 Views

Oracle has released Java 9 version with a rich set of new features and brings a lot of new enhancements.Below are a few important features and enhancements introduced in Java 9.Factory Methods for Collections: Factory methods are special kinds of static methods that can be used to create unmodifiable instances of collections, which means we can use these methods to create a list, set, and map.Java Platform Module System (JPMS): A Java Module is a mechanism to bundle java applications and java packages into a Java module. It specifies which of the java packages that contain visible to other java modules by using ... Read More

Get List of MySQL Server-Side Help Categories

seetha
Updated on 11-Feb-2020 07:58:27

131 Views

We can get the list of MySQL server-side help categories by giving the keyword contents to the help command.mysql> help contents You asked for help about help category: "Contents" For more information, type 'help ', where is one of the following categories:    Account Management    Administration    Compound Statements    Data Definition    Data Manipulation    Data Types    Functions    Functions and Modifiers for Use with GROUP BY    Geographic Features    Help Metadata    Language Structure    Plugins    Procedures    Storage Engines    Table Maintenance    Transactions    User-Defined Functions    Utility

Advertisements