A PPT On C Language
A PPT On C Language
-- other statements
}
• The files that are specified in the include
section is called as Header File.
• These are precompiled files that has some
functions defined in them.
• We can call those functions in our
program by supplying parameters.
• Header file is given an extension .h .
• C Source file is given an extension .c .
• This is the “Entry Point” of a program.
• When a file is executed, the start point is
the main function.
• From main function the flow goes as per
the programmers choice.
• There may or may not be other functions
written by user in a program.
• Main function is compulsory for any C
program.
• Type a program.
• Save it.
• Compile the program – This will generate an .exe file
(executable)
• Run the program (Actually the exe created out of
compilation will run and not the .c file)
• In different compiler we have different option for
compiling and running.
The smallest individual units in a C program are known as
tokens. In a C source program, the basic element recognized by
the compiler is the "token." A token is source-program text that
the compiler does not break down into component elements.
CONSTANTS
Real Single
Integer String
Constants Character
Constants Constants
Constants
• Integer Constants
– Refers to sequence of digits such as decimal integer, octal
integer and hexadecimal integer.
– Some of the examples are 112, 0551, 56579u, 0X2 etc.
• Real Constants
– The floating point constants such as 0.0083, -0.78, +67.89 etc.
x=a+b
z + 2 = 3(y - 5)
• Remember that variables in algebra are
represented by a single alphabetic character.
• Variables in C may be given representations containing
multiple characters. But there are rules for these
representations.
• Variable names in C :
• May only consist of letters, digits, and underscores
• May be as long as you like, but only the first 31
characters are significant
• May not begin with a number
• May not be a C reserved word (keyword)
• Should start with a letter or an underscore(_)
• Can contain letters, numbers or underscore.
• No other special characters are allowed including space.
• C is a case sensitive language.
• It matters whether an identifier, such as a
variable name, is uppercase or lowercase.
• Example:
•area
Area
AREA
•ArEa
•are all seen as different variables by the
compiler.
• Before using a variable, you must give the compiler some
information about the variable; i.e., you must declare it.
• The declaration statement includes the data type of the
•variable.
• Examples of variable declarations:
int length ;
•float area ;
• Variables are not automatically initialized. For example, after
declaration
•int sum;
•the value of the variable sum can be anything (garbage).
• Thus, it is good practice to initialize variables when they are
•declared.
• Once a value has been placed in a variable it stays there
until the program alters it.
• There are three classes of data types here::
#include <stdio.h>
Void main()
{
printf("Hello, world\n");
Getch();
}