auto

auto is the default storage class variable that is declared inside a function or a block. auto variables can only be accessed within the function/block they are declared. By default, auto variables have garbage values assigned to them. Automatic variables are also called local variables as they are local to a function. 

auto int num;

Here num is the variable of the storage class auto and its type is int. Below is the C program to demonstrate the auto keyword:

C
// C program to demonstrate 
// auto keyword
#include <stdio.h>

int printvalue()
{
  auto int a = 10;
  printf("%d", a);
}

// Driver code
int main() 
{
  printvalue();
  return 0;
}

Output
10

Keywords in C

In C Programming language, there are many rules so to avoid different types of errors. One of such rule is not able to declare variable names with auto, long, etc. This is all because these are keywords. Let us check all keywords in C language.

Similar Reads

What are Keywords?

Keywords are predefined or reserved words that have special meanings to the compiler. These are part of the syntax and cannot be used as identifiers in the program. A list of keywords in C or reserved words in the C programming language are mentioned below:...

auto

auto is the default storage class variable that is declared inside a function or a block. auto variables can only be accessed within the function/block they are declared. By default, auto variables have garbage values assigned to them. Automatic variables are also called local variables as they are local to a function....

break and continue

The break statement is used to terminate the innermost loop. It generally terminates a loop or a switch statement. The continue statement skips to the next iteration of the loop. Below is the C program to demonstrate break and continue in C:...

switch, case, and default

The switch statement in C is used as an alternate to the if-else ladder statement. For a single variable i.e, switch variable it allows us to execute multiple operations for different possible values of a single variable....

char

char keyword in C is used to declare a character variable in the C programming language....

const

The const keyword defines a variable who’s value cannot be changed....

do

The do statement is used to declare a do-while loop. A do-while loop is a loop that executes once, and then checks it’s condition to see if it should continue through the loop. After the first iteration, it will continue to execute the code while the condition is true....

double and float

The doubles and floats are datatypes used to declare decimal type variables. They are similar, but doubles have 15 decimal digits, and floats only have 7....

if-else

The if-else statement is used to make decisions, where if a condition is true, then it will execute a block of code; if it isn’t true (else), then it will execute a different block of code....

enum

The enum keyword is used to declare an enum (short for enumeration). An enum is a user-defined datatype, which holds a list of user-defined integer constants. By default, the value of each constant is it’s index (starting at zero), though this can be changed. You can declare an object of an enum and can set it’s value to one of the constants you declared before. Here is an example of how an enum might be used:...

extern

The extern keyword is used to declare a variable or a function that has an external linkage outside of the file declaration....

for

The “for” keyword is used to declare a for-loop. A for-loop is a loop that is specified to run a certain amount of times....

goto

The goto statement is used to transfer the control of the program to the given label. It is used to jump from anywhere to anywhere within a function....

int

int keyword is used in a type declaration to give a variable an integer type. In C, the integer variable must have a range of at least -32768 to +32767....

short, long, signed, and unsigned

Different data types also have different ranges up to which they can store numbers. These ranges may vary from compiler to compiler. Below is a list of ranges along with the memory requirement and format specifiers on the 32-bit GCC compiler....

return

The return statement returns a value to where the function was called....

sizeof

sizeof is a keyword that gets the size of an expression, (variables, arrays, pointers, etc.) in bytes....

register

Register variables tell the compiler to store variables in the CPU register instead of memory. Frequently used variables are kept in the CPU registers for faster access....

static

The static keyword is used to create static variables. A static variable is not limited by a scope and can be used throughout the program. It’s value is preserved even after it’s  scope....

struct

The struct keyword in C programming language is used to declare a structure. A structure is a list of variables, (they can be of different data types), which are grouped together under one data type....

typedef

The typedef keyword in C programming language is used to define a data type with a new name in the program. typedef keyword is used to make our code more readable....

union

The union is a user-defined data type. All data members which are declared under the union keyword share the same memory location....

void

The void keyword means nothing i.e, NULL value. When the function return type is used as the void, the keyword void specifies that it has no return value....

volatile

The volatile keyword is used to create volatile objects. Objects which are declared volatile are omitted from optimization as their values can be changed by code outside the scope of the current code at any point in time....

Conclusion

In this article, the points we learned about the keywords are mentioned below:...

FAQs

1. What are keywords in C?...