keywords in c programming

Keywords in c programming

Welcome to this article, here we will discuss the various reserved keywords in c language and their works.

And with the help of keywords we do various activities in programming.

There are 32 keywords in c language. And here i mention a lists of all those keywords in c language.

These keywords are:

doubleautoGotosignedunsigned
breakdefaultIfsizeofvoid
caseenumintstaticvolatile
charelselongstructwhile
continueexternregisterswitchconst
forreturntypedefdofloat
shortunion


Now we will discuss about all the types of keywords in c language. So please read the full article.

Auto :

In c language there are many types of keywords are available and auto is one of them.

In fact auto is a type of storage class, storage classes are use to define the scope and lifetime of a variable.

Basically, in the c language, there are almost four storage classes which are auto, extern, static, and register.

And the auto keyword is applies to all local variables automatically.

This is the default storage class that is why it is knpwn as an automatic variable.

Example of auto keyword:

#include<stdio.h>

int main()

{

int a =10;

auto int b =10;

clrscr();

printf(“%d %d”,a,b);

getch();

return 0;

}

output:

10 10 //here the output will come 10 in both the cases because that means that when you use the auto keyword in front of datatype then that is ok or otherwise the compiler put the auto keyword in front of datatype as well.

Double :

We know that in c language there are almost five primitive data type which are int , char ,float,double and void.

Primitive data type are those datatype which are which are keyword as well as datatype.

Double is a keyword and datatype which is used to declare the decimal numbers .This can contain 15 digits.

Goto :

In our c programming language, goto is a keyword which is uses for jump statement,and it is also use to change the location in a function from one place to another place.

Syantax:

goto label;

lines to be executes

label:

example:

#include<stdio.h>

int main()

{

int n;

printf(“enter number…”)

scanf(“%d”,&n);

if(n%2==0)

goto even;

else

goto odd;

even:

printf(“even”);

exit(0);

odd:

printf(“odd”);

return 0;

}

In the uppper section we create a programme and use the goto keyword there,and the programme tells us that at first we create an integer type variable and with the help of scanf function we got users input there.

And after that we provide a condition,if the number is divisible with 2 and gives us the remender 0 then it moves on the even and does not go into else function but if the number is divided by 2 and the remender does not come 2 then it moves onto odd function.

keywords in c programming

Signed :

In c programming langage signed and unsigned are used to define positive or negitive numbers,through the signed keyword we can store any kind of numerical values that can be either positive or negitive.

Unsigned :

With the help of this keyword we cannot store any negetive numbers because it only can store positive numbers with this keyword.

Break :

We know that break is a keyword and we only should have to write the break keyword in lowercase only.

When we use any kind of loop in our programming at that time to break that loop in the middle of the programming we use the break keyword.

We can also use this keyword to break the switch case statement.

Default :

Default is a keyword which we normally used inside our switch case statement.

So in a programme there are three keywords are used switch,case and default.

In switch we write some expression and if the expression becomes true then we move into our next case constant or otherwise our default statement will run.

If:

In c language we can used the decision control instruction in three methods by applying if or if else or through conditional operator.

Syntax:

if(3>4)

{

printf(“bye”);

}

This is a perfect syntax of c programming if statement ,here the syntax actually telling us that the condition in between the if expression then the bye is not printed by browser ,but if we change the condition and give 4>3 then the bye will printed by our browser.

Size of :

Sizeof is a kind of unary operator and within the parentheses we can write any kind of data type,variable and constant.

Example:

sizeof(data type)

sizeoof(variable)

sizeof(constant)

this is an example of sizeof operator about how t use that,within the parentheses we can write any kind of thing according to our requirements.

Void :

We normally use the void keyword inside our function, actuallyvoid means empty, when we return something through our function at that time we have to write void keyword ,or we can also say this a primitive datatype.

Switch and case :

Switch and case both are the different keyword in c langage ,but they use together in programming.

This is little bit similar to if else but if there are several options then instead of if else it is better to use the switch case statement.

Default is also used with the switch and case statement.

syntax:

switch(expression)

{

case constant:code;

case constant:code;

default:code;

}

Enum :

We know that in c language there are two types of function predefined function and and user defined function.

And enum and enumeration is a kind of user defined function and through this keywrd we can easily read our programme.

And further more through this keyword we can create enum kind of data type.

Int :

In c language int is a type of keyword which is also a data type ,these are also known as primitive data types.

According to 16 bit archhitecture int creates 2 bytes memory but according to 32 bit architecture it create 4 bytes memory.

We can use two format specifier such as-%d and %i when we want to print this data type.

Static:

In c programming language static is a reserved keyword.

We can use this keyword with the functions as well as with variables.

We can use this static keyword inside or outside our functions ,according to our requirements.

Volatile :

It is a type of qualifier , and it is used with the variable when the variable was declared.

It indicates that the variable value change at any point of time.

Char :

It is a datatype as well as a keyword which is used to store the character variable.

Generally the character variables are written within the single quotation.

Else :

We have to use the else statement with the if statement.

That means without the if statement we cannot write the else statement.

Synatx:

if(condition)


{

lines to be executed

}

else

{

lines to be executes

}

here the synatx is actually telling us that whenever the if condition will become true then the first lines will execute or otherwise the else lines will be execute.

Long :

Long is a keyword and data type in c programming language.

It is mainly use to stores the 64 bit integer value.

Struct :

In c programming language struct is used to create structure.

And structure is a data type which is created by the user, through this keyword we can define groups in data types.

While :

In c language while is used to create loops,there are three loops in c,While,do while and for.

Suppose if you want to print your name 5 times then you can do that easily with the help of while loop.

Syntax:

while(condition)

{

printf(“print something”)

}

This is a perfect example of while loop,here the syntax is telling us that whenever the while condition becomes true then it will come inside the curli brackets and print something will printed and whenever the condition becomes falls then it ignores the programme and nothing will be print.

Continue :

keywords in c programming

The works of the continue word is almost similar to the break statement or break keword.

Where break is used to terminate our programme in the middle there the continue statement is used to continue our next loop programme.

This keyword is mostly used inside the loops.

Extern :

Extern keyword is mostly used with the functions and variables.

When we use the extern keyword inside our function we can declare it without define it.

Register :

It is a keyword as well as a hint in our programming and it indicates our compiler to store the variable in cpu not stores that inside of memory.

Switch :

Switch is a kind of control instruction in our programming,and we use the switch keyword with the case statement.

Const :

By using the const keyword we can create data type inside programming.

And its default value is 0. And it is initializes only once in our programme.

For :

In c language for is a keyword which indicates the loops in programming

syntax:

int i;

for(i=1;i<=5;i++)

{

printf(“print something”);

}

Here the syntax tells us that we store 1 variable in i and after it will check the condition,if the condition becomes true then it enters in the printf and from their it check the flow and increase the values.

Return :

This keyword is normally used inside the function.

And this statement is normally ends our function.

Typedef :

This is a keyword which use with the variable.

It is normally used to change the variable names that we already define earlier.

Do :

We normally use the do keyword with the while keyword ,infact do while are used together in programming.

Do while indicates loops in programming.

Float :

We know that there are five data type in our programming and float is one of them, through this keyword we can build those variables which only consist point numbers.

Union:

If you want to store the various data types in the similar location then you can do that easily with the help of union.

In other words, it is a type of user define data type through which we can store different things.

Conclusion:

Here in this article we discussed about the various keywords in c programme ,we will definitely discuss about all the types of keywords in c language in details in later articles.

So follow our websites for this kind of informational knowledge and aticles.

Also read

Variables in c programming language
Operators in c programming language
Unary operators in c programming
Best youtbe channels to learn about c programming
Printf function in c programming
Syntax of c program
Best editor for c programming