2. History
• C is a general-purpose, low-level language that was originally developed by
Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was
originally first implemented on the DEC PDP-11 computer in 1972.
• In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly
available description of C, now known as the K&R standard.
• The UNIX operating system, the C compiler, and essentially all UNIX
application programs have been written in C. C has now become a widely
used professional language for various reasons
3. Why use C?
• C was initially used for system development work, particularly the programs that
make-up the operating system. C was adopted as a system development language
because it produces code that runs nearly as fast as the code written in assembly
language. Some examples of the use of C might be −
• Operating Systems
• Language Compilers
• Assemblers
• Text Editors
• Print Spoolers
4. Why use C?
• Network Drivers
• Modern Programs
• Databases
• Language Interpreters
• Utilities
5. First Programming “Hello world”
• A C program basically consists of the following parts −
• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
6. Environment Set & Execute Programm
• Text Editor or Use NotePad
• Notepad++
• Visual Studio Code
• Turbo C++
7. C Programming Structure
• #include<stdio.h> //using Header file
• int main(){ //Declaration function with type
• //Statement code here
• getch(); // stop Console to Display // some Editor don’t need gecth(); like Dev-C++
• Return 0; //Return Value of Function Type
• };
8. Explain Structure
• #include<stdio.h> Header File or Preprocessor use Standard Library for
Input/output files stream.
• Int main(){} Function Declaration in C programming Language,Int
Keyword must return Value to terminate program and Main() is Basic
Function to Execute program.
• inside Main Function area contain Code statements such as
function,Variable,structure,statement to instruct the programm
10. Keyword in C
• Keyword is Special word Use to Declare variable and Function.
• In C Programming We can Use Many Difference Keyword:
11.
12. Data Type
Sr.No. Types & Description
1
Basic Types
They are arithmetic types and are further classified into: (a) integer types and (b) floating-
point types.
2
Enumerated types
They are again arithmetic types and they are used to define variables that can only assign
certain discrete integer values throughout the program.
3
The type void
The type specifier void indicates that no value is available.
4
Derived types
They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e)
Function types.
13. Integer Types
Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes
-32,768 to 32,767 or -2,147,483,648
to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 8 bytes or (4bytes for 32 bit OS)
-9223372036854775808 to
9223372036854775807
unsigned long 8 bytes 0 to 18446744073709551615
14. Floating-Point Types
Type Storage size Value range Precision
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to 1.7E+308 15 decimal places
long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places
15. The void Type
Sr.No. Types & Description
1
Function returns as void
There are various functions in C which do not return any value or you can say they return void. A
function with no return value has the return type as void. For example, void exit (int status);
2
Function arguments as void
There are various functions in C which do not accept any parameter. A function with no parameter can
accept a void. For example, int rand(void);
3
Pointers to void
A pointer of type void * represents the address of an object, but not its type. For example, a memory
allocation function void *malloc( size_t size ); returns a pointer to void which can be casted to any
data type.
16. Variable and Constant
• Variable use to storage data value when we declare with Types.
• Variable can reuse and change value
• Variable can declare with Datatype :int,string,Double,char,…….
• Syntax:Type variable_name
• Exp :int age=12; string name=“sophoeut”……….;
17. Constant
• Costant use similar to variable,but it value fixed can’t change value when
declared and Assigned values.
• Like variable declaration but just add Keyword const
• Const double PI=3.14; that value can’t change even where it use.
18. C input/output
• Input mean that user input data value via Devices like Keyboard to Programm, in C
program, scanf(); is standard input keyword for read data from user input.
• Output mean than display result to screen after program compiled and executed
• Printf(); is use to print statement of program
• Both input and output files stream use standard Library in header file <stdio.h>
19. Example C input/output
• #include<stdio.h>
• Int main(){
• Int a;
• Printf(“Enter value of A:”);
• Scanf(“%d”,&a);
• Printf(“Value of A is:”&a);
• }
20. C operator
• C operator are symbol character use to operate between two or more value type.
• There many operator:
• Arithmetic(+ , - ,* ,/ , %)
• Logical(&& ,|| , ! )
• Assignment(=, +=, -=, *= ,/=, %= )
• Decrement or increment(++,--)
22. Control structure in C
• If statement
• Loop statement
• Switch statement
• Goto statement
23. If Condition
• If condition is a logical statement of programming language.it work to test
one or more Logical test to display Statement.
• In C programming Language like other ,C++,Java is the same syntax.
• If(condition){
//logical body
//some code goes here
}
24. Example of If Statement
• Int a=10;
• Int b=6;
• If(a<b){
• printf(“show compare value=”,(a<b))
}
//output will show false, because a is greater than b.
25. Example of If Statement(conti)
• If(condition1){
//statement condition 1
}else if(condition2){
//statement condion 2
}else{
// default condition statement
}
26. Loop structure
• Loop structure is the one main of control structure in C programming
Language like other language: C++ ,Java or C#,It repeatly work as same time
until end of Condition.
1. While loop
2. Do while loop
3. For loop
27. While loop
• Syntax:
• While(condition){
//Loop body
//some code goes here
}
Ex: while(i<5){
Printf();
}
28. Function in C
• There are two type of function are:
1. Standard Library function(Built-in type functions)
2. User-defined function(create multi purpose function by users)
Built-in type function use from standard library resource and declare in header files
#include<stdio.h> this header file use to Extract functions in <stdio.h> library
Example: printf(); function.
Scanf(); function;
29. User-defined functions in C
• Syntax to create function: Keyword or Type function_Name(){}
• Example: int getid(){
//some code goes here
Return 0;
}
• Note
30. Array in C
• Array is a variable but contain Multiple values with same type call collection of Elements.
Array are divide two type:
1. One dimensional array
2. Multi-dimensional array
Also are two class : bound index and unbound index array.
Declare one dimensional- array with unbound index : int a[ ]; char s[ ];
Declare one dimensional- array with bound index : int a[5 ]; char s[ 15];
Example: int a[ ]={4,5,6,12};
char str[ ]={‘A’,’B’,’C’};
31. Using array(conti.)
• Multi-dimensional array: int num [ ,] ={{2,3,5},{6,7,12,9}};
• Another way to declare multi dimensional with bound index
• Int num[2][ 3]={{2,3},{4,6,5}};
32. Pointer
• Pointer is a variable that values is the address of another variable. It use to
define memory address location of variable.
int var=20; //actual variable declare
int *ip; // poiter variable declare
ip=&var; // store address of var in address poiter
printf(“poiter address is %p”,&var); // output is display with hexadecimal
33. String
• String is define as the sequence of characters that contain Unicode characters
• Example: char str[ ]=“Hello C”;
• String is allocated to memory address by index and pointer address.
• see example…
34. Structure
• Structure are similar to array in C, array combine data items with same type.
• But Structure allow combine more data items with difference types.
• Example we want to store records about book that contain items:
• Boo_kid
• Book_name
• Date
• price
35. Structure(conti.)
• Syntax:
struct(Keyword) [struct tag]{ struct book{
member definition; int book_id[10];
member definition; char book_name[50];
}[one or more structure variables]; char date[20];
float prize[10];
}