5,890 views

3 Answers

1 votes
1 votes

Variable Definition in C

A variable definition tells the compiler where and how much storage to create for the variable. A variable definition specifies a data type and contains a list of one or more variables of that type as follows −

type variable_list;

Here, type must be a valid C data type including char, w_char, int, float, double, bool, or any user-defined object; and variable_list may consist of one or more identifier names separated by commas. Some valid declarations are shown here −

int    i, j, k;
char   c, ch;
float  f, salary;
double d;

This is all about basics which is required to solve your question.

All the 4 declarations that u have given is perfect But One thing when u go print tha value of PI , u have to use proper format specifier 

like: for int  -  u have to use '%d'

      for float  -  u have to use "%f"

      for double - "%d"

---------------------------------------------------------------------------

#define PI 3.14: this is macro definition i think. So when we want to print 3.14 in place of PI then we have to use format specifier " %f "...

Related questions

2 votes
2 votes
1 answer
1
anonymous asked Apr 16, 2017
3,213 views
4. Which of the following is not a valid variable name declaration and why?a) float PI = 3.14;b) double PI = 3.14;c) int PI = 3.14;d) #define PI 3.14
1 votes
1 votes
1 answer
2
Naveen Kumar 3 asked Jul 29, 2017
696 views
main ( ){int a = 2, b, c;a* = b = c = 4;a = b = c;printf (“%d”, a);a = = (b = c);printf (“%d”, a);}What will be the output?Not able to understand !!
0 votes
0 votes
1 answer
3
2 votes
2 votes
1 answer
4