Wednesday, 14 May 2014

Computer Programming - Keywords

Post By: Hanan Mannan (H.M.R.A Group Engineer)
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------

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 orfloat 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 

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 

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:
autoelselongswitch
breakenumregistertypedef
caseexternreturnunion
charfloatshortunsigned
constforsignedvoid
continuegotosizeofvolatile
defaultifstaticwhile
dointstruct_Packed
double   

Java programming reserved keywords

Here is a table having almost all the keywords supported by Java Programming language:
abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile

Python programming reserved keywords

Here is a table having almost all the keywords supported by Java Programming language:
andexecnot
assertfinallyor
breakforpass
classfromprint
continueglobalraise
defifreturn
delimporttry
elifinwhile
elseiswith
exceptlambdayield
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.

0 comments:

Post a Comment