basic c programming
DESCRIPTION
Basic of C Programming Language..TRANSCRIPT
-
BASICC PROGRAMMING LANGUAGE TUTORIAL
infobizzs.com
-
WHAT IS C LANGUAGE:-
C is mother language of all programming language.
It is system programming language.
It is procedure-oriented programming language.
It is also called mid level programming language.
infobizzs.com
-
HISTORY OF C LANGUAGE:-
C programming language was developed in 1972 by Dennis Ritchie at bell
laboratories of AT&T(American Telephone & Telegraph), located in U.S.A.
Dennis Ritchie is known as founder of c language.
It was developed to be used in UNIX Operating system.
It inherits many features of previous languages such as B and BPCL.
infobizzs.com
-
Language year Developed By
ALGOL 1960 International Group
BPCL 1967 Martin Richards
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K & R C 1978 Kernighan & Dennis
Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standardization Committee
infobizzs.com
-
FEATURES OF C LANGUAGE:-There are many features of c language are given below.
1) Simple
2) Machine Independent or Portable
3) Mid-level programming language
4) structured programming language
5) Rich Library
6) Memory Management
7) Fast Speed
8) Pointers
9) Recursion
10) Extensible
infobizzs.com
-
FIRST PROGRAM OF C LANGUAGE:-
#include
#include
void main(){
printf("Hello C Language");
getch();
}
infobizzs.com
-
PREPROCESSOR DIRECTIVES
#include
#include
#include
#include
#include
The #include directives paste the contents of the files like stdio.hand conio.h into your source code, at the very place where the directives appear.
infobizzs.com
-
These files contain information about some library functions used in the program:
stdio stands for standard I/O,
conio stands for console I/O
stdlib stands for standard library,
string.h includes useful string manipulation functions.
Want to see the files? Look in /TC/include
infobizzs.com
-
GLOBAL DECLARATION#define MAX_COLS 20
#define MAX_INPUT 1000
The #define directives perform global replacements:
every instance of MAX_COLS is replaced with 20, andevery instance of MAX_INPUT is replaced with 1000
infobizzs.com
-
commonly used stdio.h functions:
printf() Output function
Syntax:
printf(.) ;
scanf() Input function
Syntax:
scanf(format specifier, &var,&var2);
infobizzs.com
-
commonly used conio.h functions:
clrscr()
Used to clear the screen
getch()
Used to get a character from ouputscreen to come into the edit screen.
infobizzs.com
-
Comments
Text surrounded by /* and */ is ignored by computer
Used to describe program
int main()
Programs execution starts from the main function
Parenthesis used to indicate a function
int means that main "returns" an integer value
Braces ({ and }) indicate a block
The bodies of all functions must be contained in braces
infobizzs.com
-
CHARACTER SET
256 characters are allowed in C.
A Z : 65 to 90 26
a z : 97 to 122 26
0 9 : 48 to 57 10
Special symbols[ #, &, `] 32
Control characters[\n, \t . ..] 34
Graphic characters 128
Total 256
infobizzs.com
-
DATA TYPES
1] Primary
Integer
Float
Double
Character
2] Derived
Arrays
Pointers
Structure
infobizzs.com
o C support several different types of data, which may be
represented differently within the computers memory.
o Types
3] User Defined
typedef
enum
-
PRIMARY DATA TYPES
Data Types Byte Format Specifier
1] char 1 %c
signed char 1 %c
unsigned char 1 %c
2] short 2 %d
short signed int 2 %d
short unsigned int 2 %u
3] int 2 %d
signed int 2 %d
unsigned int 2 %u
infobizzs.com
-
Data Types Byte Format
Specifier
4] long 4 %l
long signed int 4 %ld
long unsigned int 4 %lu
5] float 4 %f
signed float 4 %f
unsigned float 4 %uf
6] double 8 %lf
7] Long Double 10 %Lf
infobizzs.com
-
TYPE CASTING
It is used to convert on data at a time.
We can have two types of type casting. Implicit Explicit
o Implicit : This converts narrow type to wider type sothat use can avoid the information to the system.
Explicit : Explicit type casting is done by theprogrammer manually. When the programmerwants a result of an expression to be in particulartype, then we use explicit type casting. This typecasting is done by casting operators ( ) and datatype.
infobizzs.com
-
TYPE CASTING EXAMPLE#include
void main ( )
{
int base, height, area;
base = 5;
height =3;
area = (base * height)/2;
printf ( Area = %d \n, area);
}
Output : Area = 7 But Incorrect .
infobizzs.com
-
#include
void main ( )
{
int base, height, area;
base = 5;
height = 3;
area = ((float) (base * height)/2); //explicite type casting
printf ( Area = %d \n, area);
}
Output : Area = 7.5 .Correct
infobizzs.com
-
USER DEFINED DATA TYPE
[A] Type Definition
Allows user to define an identifier that would represent an existing data type
Syntax: typedef type identifier
Eg: typedef int units;
units batch1, batch2;
infobizzs.com
-
[B] Enumerated data type
Syntax: enum identifier { value1, value2... valuen}
Eg: enum day{ Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}
infobizzs.com