SlideShare a Scribd company logo
1 of 39
Basic C programming
Basic Guide to Beginner Programmer
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
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
Why use C?
• Network Drivers
• Modern Programs
• Databases
• Language Interpreters
• Utilities
First Programming “Hello world”
• A C program basically consists of the following parts −
• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
Environment Set & Execute Programm
• Text Editor or Use NotePad
• Notepad++
• Visual Studio Code
• Turbo C++
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
• };
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
Explain Structure(con..)
• getch(); function to Terminate console of program
• Return 0; return function type and Terminate program.
Keyword in C
• Keyword is Special word Use to Declare variable and Function.
• In C Programming We can Use Many Difference Keyword:
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.
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
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
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.
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”……….;
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.
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>
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);
• }
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(++,--)
C operator(con..)
• Relational (==, < , >, <= , >= , !=)
• Bitwise(& ,| , <<, >> ,^ , ~)
Control structure in C
• If statement
• Loop statement
• Switch statement
• Goto statement
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
}
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.
Example of If Statement(conti)
• If(condition1){
//statement condition 1
}else if(condition2){
//statement condion 2
}else{
// default condition statement
}
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
While loop
• Syntax:
• While(condition){
//Loop body
//some code goes here
}
Ex: while(i<5){
Printf();
}
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;
User-defined functions in C
• Syntax to create function: Keyword or Type function_Name(){}
• Example: int getid(){
//some code goes here
Return 0;
}
• Note
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’};
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}};
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
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…
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
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];
}
Unions
Input & output
Preprocessors
Header file

More Related Content

What's hot (20)

Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c language
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Pc module1
Pc module1Pc module1
Pc module1
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
C tokens
C tokensC tokens
C tokens
 
C
CC
C
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
 
Programming in C- Introduction
Programming in C- IntroductionProgramming in C- Introduction
Programming in C- Introduction
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 
The smartpath information systems c pro
The smartpath information systems c proThe smartpath information systems c pro
The smartpath information systems c pro
 
C++ Tokens
C++ TokensC++ Tokens
C++ Tokens
 
Ch6
Ch6Ch6
Ch6
 
C programming
C programmingC programming
C programming
 
C tutorial
C tutorialC tutorial
C tutorial
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 

Similar to C programming tutorial for Beginner

Similar to C programming tutorial for Beginner (20)

M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plus
 
C programming language
C programming languageC programming language
C programming language
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
C intro
C introC intro
C intro
 
C programming notes
C programming notesC programming notes
C programming notes
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Funa-C.ppt
Funa-C.pptFuna-C.ppt
Funa-C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
C programming basic pdf.ppt
C programming basic pdf.pptC programming basic pdf.ppt
C programming basic pdf.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C--C Basics------------------.ppt
Basics of C--C Basics------------------.pptBasics of C--C Basics------------------.ppt
Basics of C--C Basics------------------.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 

C programming tutorial for Beginner

  • 1. Basic C programming Basic Guide to Beginner Programmer
  • 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
  • 9. Explain Structure(con..) • getch(); function to Terminate console of program • Return 0; return function type and Terminate program.
  • 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(++,--)
  • 21. C operator(con..) • Relational (==, < , >, <= , >= , !=) • Bitwise(& ,| , <<, >> ,^ , ~)
  • 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]; }