Presented By:: Gaurav Juneja
Presented By:: Gaurav Juneja
Gaurav Juneja
Introduction
C is a general purpose language which is very
closely associated with UNIX for which it was
developed in Bell Laboratories.
Most of the programs of UNIX are written and run
with the help of 'C'.
Many of the important ideas of 'c' stem are from
BCPL by Martin Richards.
In 1972, Dennies Ritchie at Bell Laboratories wrote C
Language which caused a revolution in computing
world .
From beginning C was intended to be useful for busy
programmers to get things done easily because C is
powerful,dominant and supple language.
Why Name 'C' was given to this
language?
#include<stdio.h>
Header Files
#include<conio.h>
Entry Point Of
Program
void main()
Indicates Starting
{ of Program
-- other statements
}
Header files
CONSTANTS
Real Single
Integer String
Constants Character
Constants Constants
Constants
Constants Examples
• 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.
Naming Variables
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.
Case Sensitivity
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.
Declaring Variables
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.
Data types in ‘ansi c’
• There are three classes of data types here::
#include <stdio.h>
Void main()
{
printf("Hello, world\n");
Getch();
}