C++ Syntax Question:

How to Declaring Variables in C++?

Tweet Share WhatsApp

Answer:

To declare a variable you use the syntax "type <name>". Here are some variable declaration examples:
1- int x;
2- char letter;
3- float the_float;
It is permissible to declare multiple variables of the same type on the same line; each one should be separated by a comma.
1- int a, b, c, d;
If you were watching closely, you might have seen that declaration of a variable is always followed by a semicolon (note that this is the same procedure used when you call a function).</name>

Download Basic C++ Syntax PDF Read All 27 Basic C++ Syntax Questions
Previous QuestionNext Question
Write a short code using C++ to print out all odd number from 1 to 100 using a for loop?How to demonstrate the use of a variable?