Variable declaration? String Vs Char (* pointer) Vs Char (array)?

All QuestionsCategory: Cpp LanguageVariable declaration? String Vs Char (* pointer) Vs Char (array)?
Anonymous asked 2 years ago
1 Answers
Anonymous answered 2 years ago

A typical variable declaration is of the form: 
 

// Declaring a single variable
type variable_name;

// Declaring multiple variables:
type variable1_name, variable2_name, variable3_name;

A variable name can consist of alphabets (both upper and lower case), numbers and the underscore ‘_’ character. However, the name must not start with a number.

// Create a string variable
string greeting = "Hello";
// Declaring float variable
float simpleInterest; 

// Declaring integer variable
int time, speed; 

// Declaring character variable
char var;