Professional Documents
Culture Documents
Unit1-Class 3&4 PIC
Unit1-Class 3&4 PIC
Unit1-Class 3&4 PIC
C language is very popular language among all the languages. The structure of a C program is a
protocol (rules) to the programmer, while writing a C program. The general basic structure of C
program is shown in the figure below.
Program Code
#include <stdio.h>
void main()
C=A+B;
getch();
Character Set : The characters that can be used to form words and expressions depends upon the computer to
which the program is run.
The Characters in C are
1. Letters: A-Z, a-z, both upper and lower case.
2. Digits: 0-9.
3. Special character: + - * / % ? < > ~ ! @ # $ & ( ) { } [ ] | \ etc
4. White spaces are newline, horizontal tab, blank space .
Keywords: Keywords are those words whose meaning is already defined by the compiler. Keywords cannot be used as
variable name. No header file is needed to include the keywords. Keywords should be written in lower case letters.
Keywords are also called has reserved words. There are 32 keywords in C.
• mon=3
• int a;
• char 1
• int 2
• float 4
• long
Identifiers: In C Programming, identifiers are names given to C entities, such as
variables, functions, structures etc. identifiers are created to give unique name to C
entities to identify it during the execution of program.
Variables: A Variable is a name give to memory location where the actual data is stored.
To indicate the memory location, each variable should be given a unique name
called identifier.
Floating Constants: floating constants contains decimal value. Example: 2.5, 5.521, 3.14
etc.
Character Constants: A single character constant is given within a pair of single quote.
String Constant: These are the sequence of character within double quote. Example: “GKMV”,
“India”, “4”
In C data types are defined as the data storage format that a variable can store a data to perform a
specific operation.
Variable(data) should be declared before it can be used in program. Data types are the keywords,
which are used for assigning a type to a variable.
C language is rich of data types.
A variable declaration provides assurance to the compiler that there is one variable existing with the
given type and name so that compiler proceed for further compilation. A variable declaration has its
meaning at the time of compilation only, compiler needs actual variable declaration at the time of
linking of the program.
A variable declaration has the form:
type variable_list;
Here type must be a valid C data type. The variable_list may consist of one or more identifier names
separated by commas.
Some of the valid declaration are shown below.
int a, b; char ch;
float sum, average;
Variables may be initialized at the time of declaration by assigning a value to them as show in
the below example:
#define PI 3.141593 defines a symbolic constant PI whose value is 3.141593. When the program is
pre-processed, all occurrences of the symbolic constant PI are replaced with the replacement text
3.141593.
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations. C language is rich in built-in operators and provides the following types of
operators.
a)Arithmetic operators
C provides all the basic arithmetic operators, they are +, -, *, /, % Integer division truncates
any fractional part. The modulus division produces the remainder of an integer division.
Assume variable A holds 7 and variable B holds 2 then:
Relational operator‟s checks relationship between two operands. If the relation is true, it returns
value 1 and if the relation is false, it returns value 0.
!(A==5)
! Called Logical NOT Operator. Use to reverses the
returns false.
logical state of its operand. If a condition is true
then Logical NOT operator will make false.
Example for ==
A==B
It checks whether the value of A and B are equal or not. Consider A=5 and
B=8;
A==B
It checks whether the value of A and BByare equal or not.
Neetha S.S, Dept of Computer Applications