c_help
Short Description
c notes...
Description
C Language introduction -=-=-=-=-=-=-=-=-=-=-=-=LANGUAGES : ----------A set of statements is called a Language. There are four types of languages according to their time. I Generation Languages : -----------------------These languages are Machine languages. To write programs in these languages the system technology must be required. The data is non-portable. That means a program written in a system does not work in another systems. II Generation Languages : ------------------------These are Assembly Languages. These are also system oriented that means to write any program in a system that system's technology must be required and data is non-portable. But they used MNEMONIC words in programs. That means they used a single word instead of more words. III Generation Languages : -------------------------In these languages programs are witten in general english language. There is no need to know the system technology and the data can be transfered anywhere. IV Generation languages : ------------------------These languages are defined in any one of the above languages. These are also called as packages. Here I & II Generation languages are called Low Level Languages and III & IV generation languages are called High Level Languages. For high level languages we have to use translaters to translate the source code written in general english language into machine language. These translaters are two types. 1) Interpreters, 2) Compilers. 1) Interpreters : ----------------These translaters translate the source code step by step into machine language until any error. If there is any error it stops and shows some message. After correction it can continue. Ex : BASIC, DBase III+, ....
1
2) Compilers : -------------These translaters translate the entire source code into machine language when it is error-free and creates an object file in machine language. If there is any error it shows the list of error. After debugging it creates the object file. Ex: COBOL, C, C++, ... C --The language 'C' was designed by Dennis Ritchie at AT & T Bell Laboratories. The standardised C was released in 1979. The 'C' language is used to develop i) Scientific applications, ii) Business applications, iii) Graphical applications (Ex: WINDOWS ), iv) System programs, v) Operating Systems (Ex: UNIX) , ... Character Set : --------------alphabets digits ==> Programs special symbols ---
==>
constants, variables, keywords
statements, ==> instructions
Constants : ----------The unchangeable quantities are called Constants. The constants are generally two types. 1) Character constants : a) Characters Ex: 'a', '5', '+', ' ', ... b) Strings Ex: "abc", "435", 'rama", ... 2) Numeric Constants : a) integers Ex: 435, -657, 65535, -32768,... b) Real numbers i) Fractional form Ex: 435.67, 345.00054, ... ii) Exponential form Ex: 0.02e3, 1.17e-38, ... Variables : -----------The quantities which can be changed during the execution of program are called Variables. A variable can be considered as the name of the cell which can hold the constants. To use any variable it must be declared with its data type before the first executable statement and they can be initialised. 2
Naming the variable is very important. 1) The variable name must be start with either alphabets or an underscore and may contain alphabets, digits, hyphen or underscore. 2) The maximum length of a variable is 8 characters. But some compilers can accept upto 32 characters. 3) There must not be any blank spaces or special symbols in a variable name. 4) A variable name must not be a keyword. Ex:valid eno empname emp-name emp_name _abc ab45
invlid emp name emp(name 45abc int char
Keywords : ---------These are predefined words. There are 32 keywords in C language. These keywords can not be used as user-defined variables. Operators : ----------There are 42 operators in C language. 1) Arithmetic Operators : + - *
/
%
Ex: 100 + 40 ==> 140 100 - 40 ==> 60 100 * 40 ==> 4000 100 / 40 ==> 2 100 % 40 ==> 20 40 % 100 ==> 40 2) Assigning Operators :
=
(variable) = (constant) / (variable) / (expression) ; Ex: a = 5 b=a c = a + b -2 3) Multiple operators : +=
-= *= /= %=
Ex: a=a+3
==> a += 3 3
a a a a
= = = =
a a a a
-3 ==> a -= 3 * 3 ==> a *= 3 /3 ==> a /= 3 % 3 ==> a %= 3
4) Unary Operators : ++ -Ex : a=a+1 a=a-1
==> a += 1 ==> a -= 1
==> ==> a --
a ++ ==> ==> -- a
++ a
5) Relational Operators : ==
>
< >=
View more...
Comments