Declaration & Defination

What is the declaration in C?

  • In programming, a declaration is a statement that describes an identifier, such as the name of a variable or a function.
  •  For example, in the C programming language, all variables must be declared with a specific data type before they can be assigned a value.
  • In the Declaration of variable, the type of variable is to be specified. There are different data types in C like int, char, float. So that compiler can understand which type of data we want to store.
  • For a variable, declaration means just stating its data type along with giving it a name for memory allocation but does not allocate memory. Declaration declares an identifier and its type. In other words a function declaration declares the name of the function and the return type.
  • Memory is not allocated at the time of declaration.

What is the definition?

  • While definition means giving the value of that variable
  • The definition of a variable says where the variable gets stored. i.e., memory for the variable is allocated during the definition of the variable.
Note: In C language definition and declaration for a variable can take place at the same time.

Comments

Popular posts from this blog

Getting input in C

Unary Operator