TECHNOLOGY INSPIRATION
Technology-People-Innovation

Computer Programming - Keywords

So far, you have covered two important concepts called variables and their data types. You have seen how we have used int, long and float keywords to specify different data types. You also have seen how we named our variables to store different values.

Though this chapter is not required separately because reserved keywords are part of basic programming syntax but I kept it separate to explain it right after data types and variables to make it easy to understand.

Like int, long, and float, there are many other keywords supported by C programming language which we will use for different purpose. Different programming languages provide different set of reserved keywords, but there is one important & common rule in all the programming languages that we cannot use a reserved keyword to name our variables, which means we cannot name our variable like int or float rather these keywords can only be used to specify a variable data type.

For example, if you will try to use any reserved keyword for the purpose of variable name, then you will get syntax error, as follows:

  #include <stdio.h>    main()  {     int float;          float = 10;          printf( "Value of float = %d\n", float);  }

When you compile above program, it produces the following error:

main.c: In function 'main':  main.c:5:8: error: two or more data types in declaration specifiers      int float;  ......  

But now let's give proper name to our integer variable, then above program should compile and execute successfully:

  #include <stdio.h>    main()  {     int count;       count = 10;       printf( "Value of count = %d\n", count);  }

C programming reserved keywords

Here is a table having almost all the keywords supported by C Programming language:

auto elselong switch
break enumregistertypedef
case externreturnunion
char floatshortunsigned
const forsignedvoid
continue gotosizeofvolatile
default ifstaticwhile
do intstruct_Packed
double    

Java programming reserved keywords

Here is a table having almost all the keywords supported by Java Programming language:

abstract assertbooleanbreak
byte casecatchchar
class constcontinuedefault
do doubleelseenum
extends finalfinallyfloat
for gotoifimplements
import instanceofintinterface
long nativenewpackage
private protectedpublicreturn
short staticstrictfpsuper
switch synchronizedthisthrow
throws transienttryvoid
volatile while

Python programming reserved keywords

Here is a table having almost all the keywords supported by Java Programming language:

and execnot
assertfinallyor
break forpass
classfromprint
continue globalraise
defifreturn
delimport try
elif inwhile
elseiswith
exceptlambda yield

I know you cannot memorize all these keywords, but I listed them down for your reference purpose and to explain the concept of reserved keywords. So just be careful while giving a name to your variable, you should not use any reserved keyword for that programming language.

Labels:

Post a Comment

[blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget