The Complete List of all 32 C Programming Keywords (With Examples) (2024)

Keywords in C Programming
autobreakcasechar
constcontinuedefaultdo
doubleelseenumextern
floatforgotoif
intlongregisterreturn
shortsignedsizeofstatic
structswitchtypedefunion
unsignedvoidvolatilewhile

Description of all Keywords in C

auto

The auto keyword declares automatic variables. For example:

auto int var1;

This statement suggests that var1 is a variable of storage class auto and type int.

Variables declared within function bodies are automatic by default. They are recreated each time a function is executed.

Since automatic variables are local to a function, they are also called local variables. To learn more visit C storage class.

break and continue

The break statement terminates the innermost loop immediately when it's encountered. It's also used to terminate the switch statement.

The continue statement skips the statements after it inside the loop for the iteration.

for (i=1;i<=10;++i){ if (i==3) continue; if (i==7) break; printf("%d ",i);} 

Output

1 2 4 5 6

When i is equal to 3, the continue statement comes into effect and skips 3. When i is equal to 7, the break statement comes into effect and terminates the for loop. To learn more, visit C break and continue statement

switch, case and default

The switch and case statement is used when a block of statements has to be executed among many blocks. For example:

switch(expression){ case '1': //some statements to execute when 1 break; case '5': //some statements to execute when 5 break; default: //some statements to execute when default;}

Visit C switch statement to learn more.

char

The char keyword declares a character variable. For example:

char alphabet;

Here, alphabet is a character type variable.

To learn more, visit C data types.

const

An identifier can be declared constant by using the const keyword.

const int a = 5;

To learn more, visit C variables and constants.

do...while

int i;do { printf("%d ",i); i++;}while (i<10)

To learn more, visit C do...while loop

double and float

Keywords double and float are used for declaring floating type variables. For example:

float number;double longNumber;

Here, number is a single-precision floating type variable whereas, longNumber is a double-precision floating type variable.

To learn more, visit C data types.

if and else

In C programming, if and else are used to make decisions.

if (i == 1) printf("i is 1.")else printf("i is not 1.")

If the value of i is other than 1, the output will be :

i is not 1

To learn more, visit C if...else statement.

enum

Enumeration types are declared in C programming using keyword enum. For example:

enum suit{ hearts; spades; clubs; diamonds;};

Here, an enumerated variable suit is created having tags: hearts, spades, clubs, and diamonds.

To learn more, visit C enum.

extern

The extern keyword declares that a variable or a function has external linkage outside of the file it is declared.

To learn more, visit C storage type.

for

There are three types of loops in C programming. The for loop is written in C programming using the keyword for. For example:

for (i=0; i< 9;++i){ printf("%d ",i);}

Output

0 1 2 3 4 5 6 7 8

To learn more, visit C for loop.

goto

The goto statement is used to transfer control of the program to the specified label. For example:

for(i=1; i<5; ++i){ if (i==10) goto error;}printf("i is not 10");error: printf("Error, count cannot be 10.");

Output

Error, count cannot be 10.

To learn more, visit C goto.

int

The int keyword is used to declare integer type variables. For example:

int count;

Here, count is an integer variable.

To learn more, visit C data types.

short, long, signed and unsigned

The short, long, signed and unsigned keywords are type modifiers that alter the meaning of a base data type to yield a new type.

short int smallInteger;long int bigInteger;signed int normalInteger;unsigned int positiveInteger;
Range of int type data types
Data typesRange
short int-32768 to 32767
long int-2147483648 to 214743648
signed int-32768 to 32767
unsigned int0 to 65535

return

The return keyword terminates the function and returns the value.

int func() { int b = 5; return b;}

This function func() returns 5 to the calling function. To learn more, visit C user-defined functions.

sizeof

The sizeof keyword evaluates the size of data (a variable or a constant).

#include <stdio.h>int main(){ printf("%u bytes.",sizeof(char));}

To learn more, visit C operators.

Output

1 bytes.

register

The register keyword creates register variables which are much faster than normal variables.

register int var1;

static

The static keyword creates a static variable. The value of the static variables persists until the end of the program. For example:

static int var;

struct

The struct keyword is used for declaring a structure. A structure can hold variables of different types under a single name.

struct student{ char name[80]; float marks; int age;}s1, s2;

To learn more, visit C structures.

typedef

The typedef keyword is used to explicitly associate a type with an identifier.

typedef float kg;kg bear, tiger;

union

A union is used for grouping different types of variables under a single name.

union student { char name[80]; float marks; int age;}

To learn more, visit C unions.

void

The void keyword meaning nothing or no value.

void testFunction(int a) { .....}

Here, the testFunction() function cannot return a value because its return type is void.

volatile

The volatile keyword is used for creating volatile objects. A volatile object can be modified in an unspecified way by the hardware.

const volatile number

Here, number is a volatile object.

Since number is a constant, the program cannot change it. However, hardware can change it since it is a volatile object.

The Complete List of all 32 C Programming Keywords (With Examples) (2024)

FAQs

How many keywords are in C programming? ›

As of the C99 standard, there is a set of 32 keywords in C language, as shown in the table below. All of these keywords in C have specific meanings and are used to define control structures, data types, function declarations, and other fundamental elements in a C program.

How many keywords are there in C * 31? ›

The C language has a set of around 32 keywords (the exact number may vary slightly between different compilers), such as int, if, else, for, while, return, switch, and typedef, among others.

How many keywords are there in a C language PDF? ›

A keyword is a reserved word. You cannot use it as a variable name, constant name, etc. There are only 32 reserved words (keywords) in the C language. We will learn about all the C language keywords later.

What are the 32 keywords in Python? ›

Keywords in Python include: False, True, None, and, as, assert, async, await, def, del, elif, else, break, class, continue, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with and yield.

Are there 33 or 35 keywords in Python? ›

Syntax: Type in help followed by keywords in parenthesis. There are 35 Python keywords as of Python 3.8. Point to Note: The Python Keywords should not be confused with the built-in functions provided by Python.

Which level language is C? ›

C is considered as a middle-level language because it supports the feature of both low-level and high-level languages. C language program is converted into assembly code, it supports pointer arithmetic (low-level), but it is machine independent (a feature of high-level).

How many keywords for Python? ›

Currently there are 36 keywords in python, such as: True, False, None, And, As, Assert, async, continue, if, else, elif, except, pass, break and many more. Can python keywords are used as variable name? No, python keywords can't be used as a variable name, and in case, if you use it will throw syntax errors.

How many keywords does C++ have? ›

There are 60 key words currently defined for C++. They are shown in Table 2.3 below. Together with the formal C++ syntax, they form the C++ programming language.

Who invented C? ›

How many keywords does C# have? ›

C# has a total of 79 keywords. All these keywords are in lowercase. Here is a complete list of all C# keywords. Although keywords are reserved words, they can be used as identifiers if @ is added as prefix.

What are the total number of keywords in C? ›

These words help us to use the functionality of C language. They have special meaning to the compilers. There are total 32 keywords in C.

Is true a keyword in C? ›

In the C programming language, the keyword "true" is a constant that represents the logical value of true, which is equivalent to the integer value 1. It is commonly used in conditions to test for a true value in an if statement or a loop.

What are the examples of keywords and identifiers in C? ›

Examples of keywords are: int, char, if, while, do, class etc. Examples of identifiers are: Test, count1, high_speed, etc.

Are all keywords in C uppercase or lowercase? ›

As C is a case sensitive language, all keywords must be written in lowercase.

What is a keyword with an example? ›

Keywords are the words and phrases that people type into search engines to find what they're looking for. For example, if you were looking to buy a new jacket, you might type something like “mens leather jacket” into Google. Even though that phrase consists of more than one word, it's still a keyword.

Is printf a keyword in C? ›

It is a statement. Being a keyword is how the parser know this. printf is a function and not part of the language, only the standard library.

Top Articles
Latest Posts
Article information

Author: Golda Nolan II

Last Updated:

Views: 6321

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Golda Nolan II

Birthday: 1998-05-14

Address: Suite 369 9754 Roberts Pines, West Benitaburgh, NM 69180-7958

Phone: +522993866487

Job: Sales Executive

Hobby: Worldbuilding, Shopping, Quilting, Cooking, Homebrewing, Leather crafting, Pet

Introduction: My name is Golda Nolan II, I am a thoughtful, clever, cute, jolly, brave, powerful, splendid person who loves writing and wants to share my knowledge and understanding with you.