SlideShare a Scribd company logo
1 of 21
A PRESENTATION ON
“C LANGUAGE”
SUBMITTED BY:- MOHIT
SANKHLA
SECTION:- B
CS DEPARTMENT
SUBMITTED TO:- PAWAN KUMAR
PATIDAR
OVER VIEW OF C
»C is developed by Dennis Ritchie.
»C is a structured programming language.
»C supports functions that enables easy maintainability of code,
by breaking large file into smaller modules.
»Comments in C provides easy readability.
»C is a powerful language.
PROGRAM STRUCTURE
A sample C Program
#include<stdio.h>
int main()
{
--other statements
// Comments after double slash
}
HEADER FILES
»The files that are specified in the include section is called as
header file.
»These are precompiled files that has some functions defined in
them.
»We can call those functions in our program by supplying
parameters.
»Header file is given an extension .h.
MAIN FUNCTION
»This is the entry point of a program.
»When a file is executed, the start point is the main function
»From main function the flow goes as per the programmers
choice.
»There may or may not be other functions written by user in a
program
»Main function is compulsory for any c program
WRITING THE FIRST PROGRAM
#include<stdio.h>
int main()
{
printf(“Hello”);
return 0;
}
»This program will print hello on the screen when we
execute it.
RUNNING A C PROGRAM
»Type a program.
»Save it.
»Compile the program – This will generate an exe file
(executable).
»Run the program (Actually the exe created out of compilation
will run and not the .c file).
»In different compiler we have different option for compiling and
running. We give only the concepts.
COMMENTS IN C
»Single line comment
– // (double slash)
– Termination of comment is by pressing enter key.
»Multi line comment
/*….
…….*/
»This can span over to multiple lines.
DATATYPES IN C
»Primitive data types
– int, float, double, char
»Aggregate data types
– Arrays come under this category
– Arrays can contain collection of int or float or char or
double data
»User defined data types
– Structures and enum fall under this category.
FOR LOOPS
The syntax of for loop is
for(initialisation ; condition checking ; increment)
{
set of statements
}
WHILE LOOP
The syntax for while loop
while(condition)
{
statements;
}
DO WHILE LOOP
The syntax of do while loop
do
{
set of statements
}while(condition);
ARRAYS
»Arrays fall under aggregate data type
»Aggregate – More than 1
»Arrays are collection of data that belong to same data type
»Arrays are collection of homogeneous data.
»int a[5] is an array that stores 5 integers.
»a[0] is the first element where as a[4] is the fifth element.
»float a[5][5] is a two dimensional array. It can store 5x5 = 25
floating point numbers.
STRUCTURES
»Structures are user defined data types.
»It is a collection of heterogeneous data.
»It can have integer, float, double or character data in it.
»We can also have array of structures
struct <<structname>>
{
members;
}element;
POINTERS
»Pointer is a special variable that stores address of another
variable.
»Addresses are integers. Hence pointer stores integer data.
»Size of pointer = size of int
CALL BY REFERENCE
Calling a function with parameters passed as values
int a=10; void fun(int a)
fun(a); {
definition;
}
Here fun(a) is a call by value.
Any modification done with in the function is local to it and will
not be effected outside the function.
EXAMPLE PROGRAM – CALL BY
REFERENCE
#include<stdio.h>
void main()
{
int a=10;
printf(“%d”,a); a=10
fun(a);
printf(“%d”,a); a=10
}
void fun(int x)
{
printf(“%d”,x) x=10
x++;
printf(“%d”,x); x=11
}
CALL BY REFERENCE
Calling a function by passing pointers as parameters (address of
variables is passed instead of variables).
int a=1; void fun(int *x)
fun(&a);
{
defn;
}
Any modification done to variable a will effect outside the
function also.
EXAMPLE PROGRAM – CALL BY
REFERENCE
#include<stdio.h>
void main()
{
int a=10;
printf(“%d”,a); a=10
fun(a);
printf(“%d”,a); a=11
}
void fun(int x)
{
printf(“%d”,x) x=10
printf(“%d”,x); x=11
}
a and x are referring to same
location. So value will be over
written.
THANK YOU!
QUERIES?

More Related Content

What's hot

Understanding the components of standard template library
Understanding the components of standard template libraryUnderstanding the components of standard template library
Understanding the components of standard template libraryRahul Sharma
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsPawanMM
 
14 file handling
14 file handling14 file handling
14 file handlingAPU
 
An introduction to java programming
An introduction to java programmingAn introduction to java programming
An introduction to java programminghoshmand kareem
 
Assets, files, and data parsing
Assets, files, and data parsingAssets, files, and data parsing
Assets, files, and data parsingAly Arman
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structureshaibal sharif
 
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Jannat Ruma
 
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Jannat Ruma
 
An Introduction to the C++ Standard Library
An Introduction to the C++ Standard LibraryAn Introduction to the C++ Standard Library
An Introduction to the C++ Standard LibraryJoyjit Choudhury
 
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)Jannat Ruma
 
Design patterns for beginners (1/ 2)
Design patterns for beginners (1/ 2)Design patterns for beginners (1/ 2)
Design patterns for beginners (1/ 2)Mustapha Tachouct
 

What's hot (20)

Structure in c
Structure in cStructure in c
Structure in c
 
Understanding the components of standard template library
Understanding the components of standard template libraryUnderstanding the components of standard template library
Understanding the components of standard template library
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, Sets
 
Files in java
Files in javaFiles in java
Files in java
 
14 file handling
14 file handling14 file handling
14 file handling
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
 
An introduction to java programming
An introduction to java programmingAn introduction to java programming
An introduction to java programming
 
Assets, files, and data parsing
Assets, files, and data parsingAssets, files, and data parsing
Assets, files, and data parsing
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structure
 
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
Streams&amp;io
Streams&amp;ioStreams&amp;io
Streams&amp;io
 
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
 
An Introduction to the C++ Standard Library
An Introduction to the C++ Standard LibraryAn Introduction to the C++ Standard Library
An Introduction to the C++ Standard Library
 
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
 
Structure in c
Structure in cStructure in c
Structure in c
 
C# File IO Operations
C# File IO OperationsC# File IO Operations
C# File IO Operations
 
Design patterns for beginners (1/ 2)
Design patterns for beginners (1/ 2)Design patterns for beginners (1/ 2)
Design patterns for beginners (1/ 2)
 
Java stereams
Java stereamsJava stereams
Java stereams
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
 

Similar to Persentation on c language

Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++jamilmalik19
 
object oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxobject oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxurvashipundir04
 
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...ssuser5610081
 
Programming Language
Programming  LanguageProgramming  Language
Programming LanguageAdeel Hamid
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxRohitKumar639388
 
Oop(object oriented programming)
Oop(object oriented programming)Oop(object oriented programming)
Oop(object oriented programming)geetika goyal
 
Learn advanced java programming
Learn advanced java programmingLearn advanced java programming
Learn advanced java programmingTOPS Technologies
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2Gera Paulos
 
Ppt programming by alyssa marie paral
Ppt programming by alyssa marie paralPpt programming by alyssa marie paral
Ppt programming by alyssa marie paralalyssamarieparal
 
C++ unit-1-part-6
C++ unit-1-part-6C++ unit-1-part-6
C++ unit-1-part-6Jadavsejal
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
Data structures and algorithms 2
Data structures and algorithms 2 Data structures and algorithms 2
Data structures and algorithms 2 Mark John Lado, MIT
 

Similar to Persentation on c language (20)

C programming
C programmingC programming
C programming
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++
 
cs8251 unit 1 ppt
cs8251 unit 1 pptcs8251 unit 1 ppt
cs8251 unit 1 ppt
 
Basics of Programming.pptx
Basics of Programming.pptxBasics of Programming.pptx
Basics of Programming.pptx
 
Python training
Python trainingPython training
Python training
 
object oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxobject oriented programming part inheritance.pptx
object oriented programming part inheritance.pptx
 
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
Presentation c++
Presentation c++Presentation c++
Presentation c++
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
Oop(object oriented programming)
Oop(object oriented programming)Oop(object oriented programming)
Oop(object oriented programming)
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Learn advanced java programming
Learn advanced java programmingLearn advanced java programming
Learn advanced java programming
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
 
Ppt programming by alyssa marie paral
Ppt programming by alyssa marie paralPpt programming by alyssa marie paral
Ppt programming by alyssa marie paral
 
C++ unit-1-part-6
C++ unit-1-part-6C++ unit-1-part-6
C++ unit-1-part-6
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Data structures and algorithms 2
Data structures and algorithms 2 Data structures and algorithms 2
Data structures and algorithms 2
 
Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr Workshop
 

Recently uploaded

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Persentation on c language

  • 1. A PRESENTATION ON “C LANGUAGE” SUBMITTED BY:- MOHIT SANKHLA SECTION:- B CS DEPARTMENT SUBMITTED TO:- PAWAN KUMAR PATIDAR
  • 2. OVER VIEW OF C »C is developed by Dennis Ritchie. »C is a structured programming language. »C supports functions that enables easy maintainability of code, by breaking large file into smaller modules. »Comments in C provides easy readability. »C is a powerful language.
  • 3. PROGRAM STRUCTURE A sample C Program #include<stdio.h> int main() { --other statements // Comments after double slash }
  • 4. HEADER FILES »The files that are specified in the include section is called as header file. »These are precompiled files that has some functions defined in them. »We can call those functions in our program by supplying parameters. »Header file is given an extension .h.
  • 5. MAIN FUNCTION »This is the entry point of a program. »When a file is executed, the start point is the main function »From main function the flow goes as per the programmers choice. »There may or may not be other functions written by user in a program »Main function is compulsory for any c program
  • 6. WRITING THE FIRST PROGRAM #include<stdio.h> int main() { printf(“Hello”); return 0; } »This program will print hello on the screen when we execute it.
  • 7. RUNNING A C PROGRAM »Type a program. »Save it. »Compile the program – This will generate an exe file (executable). »Run the program (Actually the exe created out of compilation will run and not the .c file). »In different compiler we have different option for compiling and running. We give only the concepts.
  • 8. COMMENTS IN C »Single line comment – // (double slash) – Termination of comment is by pressing enter key. »Multi line comment /*…. …….*/ »This can span over to multiple lines.
  • 9. DATATYPES IN C »Primitive data types – int, float, double, char »Aggregate data types – Arrays come under this category – Arrays can contain collection of int or float or char or double data »User defined data types – Structures and enum fall under this category.
  • 10. FOR LOOPS The syntax of for loop is for(initialisation ; condition checking ; increment) { set of statements }
  • 11. WHILE LOOP The syntax for while loop while(condition) { statements; }
  • 12. DO WHILE LOOP The syntax of do while loop do { set of statements }while(condition);
  • 13. ARRAYS »Arrays fall under aggregate data type »Aggregate – More than 1 »Arrays are collection of data that belong to same data type »Arrays are collection of homogeneous data. »int a[5] is an array that stores 5 integers. »a[0] is the first element where as a[4] is the fifth element. »float a[5][5] is a two dimensional array. It can store 5x5 = 25 floating point numbers.
  • 14. STRUCTURES »Structures are user defined data types. »It is a collection of heterogeneous data. »It can have integer, float, double or character data in it. »We can also have array of structures struct <<structname>> { members; }element;
  • 15. POINTERS »Pointer is a special variable that stores address of another variable. »Addresses are integers. Hence pointer stores integer data. »Size of pointer = size of int
  • 16. CALL BY REFERENCE Calling a function with parameters passed as values int a=10; void fun(int a) fun(a); { definition; } Here fun(a) is a call by value. Any modification done with in the function is local to it and will not be effected outside the function.
  • 17. EXAMPLE PROGRAM – CALL BY REFERENCE #include<stdio.h> void main() { int a=10; printf(“%d”,a); a=10 fun(a); printf(“%d”,a); a=10 } void fun(int x) { printf(“%d”,x) x=10 x++; printf(“%d”,x); x=11 }
  • 18. CALL BY REFERENCE Calling a function by passing pointers as parameters (address of variables is passed instead of variables). int a=1; void fun(int *x) fun(&a); { defn; } Any modification done to variable a will effect outside the function also.
  • 19. EXAMPLE PROGRAM – CALL BY REFERENCE #include<stdio.h> void main() { int a=10; printf(“%d”,a); a=10 fun(a); printf(“%d”,a); a=11 } void fun(int x) { printf(“%d”,x) x=10 printf(“%d”,x); x=11 } a and x are referring to same location. So value will be over written.