closed what is the syntax for declaring a variable?

+2 votes
asked Dec 22, 2019 by kothakushal (560 points)
closed Jun 18 by Admin
closed with the note: Question is answered.

18 Answers

+1 vote
answered Dec 22, 2019 by Mahesh Morem (200 points)

syntax:

datatype variablename;

+1 vote
answered Dec 22, 2019 by Shahzain
First write the data type for the variable, such as int, float, double and then write the variable name such as a, b, c or your name or anything except the keywords. And then write the value of your variable such as 5 or 500 or 2000.
For example:
int a = 5;

float b = 4.0;
0 votes
answered Dec 23, 2019 by anonymous
[storage class] data_type variable_name [= value] // [ ] = optional

In C: type_name = value; e.g. int a;

In PHP: $name = value; e.g. $a; //No need to declar the type in PHP

Storage class = static, protected, private, public etc
0 votes
answered Dec 23, 2019 by anonymous

DataType DataName ;

DataType DataName = Value ;

0 votes
answered Dec 23, 2019 by Suhit Gupta (180 points)
#include<stdio.h>

int main()

{

int x;  // in this way u can declare a variable

return 0;

}
+1 vote
answered Dec 24, 2019 by Frank Lai (160 points)
depends on the language but generally you do:

<variable type> <variable name> (you can add =<some initializer> if you want) ;

example:

int num = 0;

string name;

bool flag;
0 votes
answered Dec 24, 2019 by RAGE MONSTER rocks (570 points)
<data_type> <variable_name> = <value>  ;
0 votes
answered Dec 26, 2019 by Prabhuchand (180 points)
datatype variablename;
0 votes
answered Jan 8 by All in one Technical Aaditya (360 points)

datatype variable_name;

int value;

int value=1;

0 votes
answered Jan 14 by Chandra Sagar (260 points)
datatype variable;

datatype may be int,float,char....etc

variable may be your name,place,a,b,c,123......etc whatever it may be
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...