1.

What is an auto keyword in C?

Answer»
  • The auto keyword is used for declaring a variable that has a complicated type. For example, an auto keyword can be used for variable declaration where the initialization expression CONSISTS of templates, pointers to members, or pointers to functions.
  • It can also be used for declaring and initializing a variable to a lambda expression. You cannot DECLARE the variable type on your own because the type of lambda expression will be only known to the compiler.
  • Auto variables can be accessed only within the block or function in which they have been declared and cannot be accessed OUTSIDE of them. By default, they are assigned with garbage value whenever they are declared without assigning any value.

Syntax: auto <data_type&GT; <variable_name>;

Example:

auto int x = 1;

Here, x is a variable of storage class “auto” and with DATA type int.



Discussion

No Comment Found