際際滷

際際滷Share a Scribd company logo
Introduction to C programming
 Character Set
 Delimiters
 Keywords
 Identifiers
 Constants
 Variables
 Data types
 Initializing variables
 Comments
 C uses
 Uppercase lettersA to Z
 Lowercase letters a to z
 Digits: 0 to 9
 Special Characters:
 + - ! # % ^ & * ? <>;.|?/
 Special combination
 b- backspace
 n- New Line
 t- horizontal tab
 a- print with alert
Introduction to C programming
 Identifiers are the name given to various
elements such as variables, functions and
array.
 Both upper and lower case letters are
permitted
 May begin with _ (underscore)
 Diff b/w - and _
1) It must consist only of letters, digits
and underscore.
2) It should not begin with a digit.
3) An identifier defined in the C
standard library should not be
redefined.
4) It is case sensitive (uppercase is not
equal to lowercase letters).
5) Do not include embedded blanks.
6) Do not use any of the C language
keywords as identifiers/variables.
7) Do not call your variable/identifier by the
same name as other functions.
Invalid declaration
1. 8area
2. Roll number
3. tax
4. Student-name
5. 4th
valid Declaration
1. area8
2. Roll_number
3. tax
4. student_name
Int area8, roll_number, tax;
 In C there are certain reserved word that we
cannot declare as variable.
 These word is known as keywor
 Keywords are reserved words that have a
special meaning in a programming language.
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
auto
break
case
char
const
continue
default
do
 There are 5 basic data types inTurbo C:
a) Character (char)  use to hold ASCII
characters.
b) Integer (int)  use to hold whole number
values
c) Floating Point (float)  use to hold real
numbers
d) Double Floating Point (double) - use to
hold real numbers
e) Void (void)  use to declare a function with
no return values, functions with no parameters
and to create generic pointers.
TYPE BITWIDTH RANGE
char 8 0 to 255 (ASCII)
int 16 -32768 to 32767
float 32 3.4E-32 to 3.4 E+38
double 64 1.7E-308 to 1.7 E+308
void 0 valueless
TYPE EXAMPLES
char A b $ 9
int 1 250 4500
float 3.5 42.56 345.6789
double 3.5647290 486.145875...
void valueless
Introduction to C programming
Examples:
char name;
int x, y,z;
float number;
float n1, n2, sum;
double counter;
 Giving a value to a variable during the
variables declaration is called variable
initialization.
Syntax:
type variable_name = value;
Example:
int count = 100;
float grade = 3.75;
char status = S;
 First step in c is declaring the variables
 Why???
 Ans: we need space to store data in
memory
 int x
 Compiler will allots a address to x and
Then compiler can store the data in that
Memory space.
Programmers insert comments to
document programs and improve
program readability.
Starts with /* and ends with */
Also for one line comment we use //
Can be placed anywhere in the program.
Comments are ignored by the C compiler.
#include<stdio.h>
#include<conio.h>
void main() // it is the main function
{
printf(Hello world); //to print hello on screen
printf(nHello world); //print with new line
printf(tHello world);
printf(aHello world);
getch();
}
with regards,
際際滷share.net/Sabik.sabz

More Related Content

Introduction to C programming

  • 2. Character Set Delimiters Keywords Identifiers Constants Variables Data types Initializing variables Comments
  • 3. C uses Uppercase lettersA to Z Lowercase letters a to z Digits: 0 to 9 Special Characters: + - ! # % ^ & * ? <>;.|?/ Special combination b- backspace n- New Line t- horizontal tab a- print with alert
  • 5. Identifiers are the name given to various elements such as variables, functions and array. Both upper and lower case letters are permitted May begin with _ (underscore) Diff b/w - and _
  • 6. 1) It must consist only of letters, digits and underscore. 2) It should not begin with a digit. 3) An identifier defined in the C standard library should not be redefined. 4) It is case sensitive (uppercase is not equal to lowercase letters).
  • 7. 5) Do not include embedded blanks. 6) Do not use any of the C language keywords as identifiers/variables. 7) Do not call your variable/identifier by the same name as other functions.
  • 8. Invalid declaration 1. 8area 2. Roll number 3. tax 4. Student-name 5. 4th valid Declaration 1. area8 2. Roll_number 3. tax 4. student_name Int area8, roll_number, tax;
  • 9. In C there are certain reserved word that we cannot declare as variable. These word is known as keywor Keywords are reserved words that have a special meaning in a programming language.
  • 11. There are 5 basic data types inTurbo C: a) Character (char) use to hold ASCII characters. b) Integer (int) use to hold whole number values c) Floating Point (float) use to hold real numbers d) Double Floating Point (double) - use to hold real numbers e) Void (void) use to declare a function with no return values, functions with no parameters and to create generic pointers.
  • 12. TYPE BITWIDTH RANGE char 8 0 to 255 (ASCII) int 16 -32768 to 32767 float 32 3.4E-32 to 3.4 E+38 double 64 1.7E-308 to 1.7 E+308 void 0 valueless
  • 13. TYPE EXAMPLES char A b $ 9 int 1 250 4500 float 3.5 42.56 345.6789 double 3.5647290 486.145875... void valueless
  • 15. Examples: char name; int x, y,z; float number; float n1, n2, sum; double counter;
  • 16. Giving a value to a variable during the variables declaration is called variable initialization. Syntax: type variable_name = value; Example: int count = 100; float grade = 3.75; char status = S;
  • 17. First step in c is declaring the variables Why??? Ans: we need space to store data in memory int x Compiler will allots a address to x and Then compiler can store the data in that Memory space.
  • 18. Programmers insert comments to document programs and improve program readability. Starts with /* and ends with */ Also for one line comment we use // Can be placed anywhere in the program. Comments are ignored by the C compiler.
  • 19. #include<stdio.h> #include<conio.h> void main() // it is the main function { printf(Hello world); //to print hello on screen printf(nHello world); //print with new line printf(tHello world); printf(aHello world); getch(); }