Post By: Hanan Mannan (H.M.R.A Group Engineer)
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------
Computer Programming - Keywords
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);
}
main()
{
int float;
float = 10;
printf( "Value of float = %d\n", float);
}
main.c:5:8: error: two or more data types in declaration specifiers
int float;
......
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 | else | long | switch |
break | enum | register | typedef |
case | extern | return | union |
char | float | short | unsigned |
const | for | signed | void |
continue | goto | sizeof | volatile |
default | if | static | while |
do | int | struct | _Packed |
double |
Java programming reserved keywords
Here is a table having almost all the keywords supported by Java Programming language:
abstract | assert | boolean | break |
byte | case | catch | char |
class | const | continue | default |
do | double | else | enum |
extends | final | finally | float |
for | goto | if | implements |
import | instanceof | int | interface |
long | native | new | package |
private | protected | public | return |
short | static | strictfp | super |
switch | synchronized | this | throw |
throws | transient | try | void |
volatile | while |
Python programming reserved keywords
Here is a table having almost all the keywords supported by Java Programming language:
and | exec | not |
assert | finally | or |
break | for | pass |
class | from | |
continue | global | raise |
def | if | return |
del | import | try |
elif | in | while |
else | is | with |
except | lambda | 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.
0 comments:
Post a Comment