SlideShare a Scribd company logo
1 of 31
C Programming Language Tutorial
BY: SURBHI SAROHA
C language
• The C Language is developed by Dennis Ritchie
for creating system applications that directly
interact with the hardware devices such as
drivers, kernels, etc.
• C programming is considered as the base for
other programming languages, that is why it is
known as mother language.
Why to Learn C Programming?
• C programming language is a MUST for students
and working professionals to become a great
Software Engineer specially when they are working
in Software Development Domain. I will list down
some of the key advantages of learning C
Programming:
• Easy to learn
• Structured language
• It produces efficient programs
• It can handle low-level activities
• It can be compiled on a variety of computer
platforms
C Supports Six Types of Tokens:
• Identifiers
• Keywords
• Constants
• Strings
• Operators
• Special Symbols
C Keyword List
• A list of 32 reserved keywords in c language is
given below:
Constants
• Constants are like a variable, except that their
value never changes during execution once
defined.
• Constants are also called literals.
• Constants can be any of the data types.
• It is considered best practice to define constants
using only upper-case names.
Example
• #include<stdio.h>
• main()
• {
• const int SIDE = 10;
• int area;
• area = SIDE*SIDE;
• printf("The area of the square with side: %d is:
%d sq. units" , SIDE, area);
• }
C operators
• C operators are symbols that are used to perform
mathematical or logical manipulations. The C
programming language is rich with built-in
operators.
• Operators take part in a program for
manipulating data and variables and form a part
of the mathematical or logical expressions.
Cont....
• C programming language offers various types of
operators having different functioning capabilities.
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Assignment Operators
• Increment and Decrement Operators
• Conditional Operator
• Bitwise Operators
• Special Operators
Arithmetic Operators
• Arithmetic Operators are used to performing
mathematical calculations like addition (+),
subtraction (-), multiplication (*), division (/) and
modulus (%).
• #include <stdio.h>
• void main()
• {
• int i=3,j=7,k;
• /* Variables Defining and Assign values */
• k=i+j;
• printf("sum of two numbers is %dn", k);
• }
Increment and Decrement Operators
• Increment and Decrement Operators are useful
operators generally used to minimize the
calculation, i.e. ++x and x++ means x=x+1 or -x and
x−−means x=x-1.
• But there is a slight difference between ++ or
−− written before or after the operand.
• Applying the pre-increment first add one to the
operand and then the result is assigned to the
variable on the left whereas post-increment first
assigns the value to the variable on the left and then
increment the operand
Relational operators
• Relational operators are used to comparing two
quantities or values.
Logical operators
• C provides three logical operators when we test
more than one condition to make decisions.
These are: && (meaning logical AND), ||
(meaning logical OR) and ! (meaning logical
NOT).
Bitwise operator
• C provides a special operator for bit operation
between two variables.
Assignment operators
• Assignment operators applied to assign the
result of an expression to a variable. C has a
collection of shorthand assignment operators.
Conditional operator
• C offers a ternary operator which is the
conditional operator (?: in combination) to
construct conditional expressions.
• C supports some special operators
Data types
• C provides three types of data types:
• Primary(Built-in) Data Types:
void, int, char, double and float.
• Derived Data Types:
Array, References, and Pointers.
• User Defined Data Types:
Structure, Union, and Enumeration.
What is Loop?
• A computer is the most suitable machine for performing
repetitive tasks, and it can perform a task thousands of times.
• Every programming language has the feature to instruct to do
such repetitive tasks with the help of certain statements.
• The process of repeatedly executing a collection of statements
is called looping.
• The statements get executed many numbers of times based on
the condition.
• But if the condition is given in such logic that the repetition
continues any number of times with no fixed condition to stop
looping those statements, then this type of looping is
called infinite looping.
Cont....
• C supports the following types of loops:
• while loops
• do-while loops
• for loops
• while loop
• It is a most basic loop in C programming. while loop
has one control condition, and executes as long the
condition is true.
• The condition of the loop is tested before the body of
the loop is executed, hence it is called an entry-
controlled loop.
The basic format of while loop
statement is:
• Syntax:
• While (condition)
• {
• statement(s);
• Incrementation;
• }
Example
• #include<stdio.h>
• int main ()
• { /* local variable Initialization */
• int n = 1,times=5;
• /* while loops execution */
• while( n <= times )
• {
• printf("C while loops: %dn", n);
• n++;
• }
• return 0;
• }
do while loops
• C do while loops are very similar to the while
loops, but it always executes the code block at
least once and furthermore as long as the
condition remains true. This is an exit-
controlled loop.
• do
• {
• statement(s);
• }while( condition );
Example
• #include<stdio.h>
• int main ()
• { /* local variable Initialization */
• int n = 1,times=5;
• /* do loops execution */
• do
• {
• printf("C do while loops: %dn", n);
• n = n + 1;
• }while( n <= times );
• return 0;
• }
for loop
• C for loops is very similar to a while loops in that
it continues to process a block of code until a
statement becomes false, and everything is
defined in a single line.
• The for loop is also entry-controlled loop.
• for ( init; condition; increment )
• {
• statement(s);
• }
Example
• #include<stdio.h>
• int main ()
• { /* local variable Initialization */
• int n,times=5;
• /* for loops execution */
• for( n = 1; n <= times; n = n + 1 )
• {
• printf("C for loops: %dn", n);
• }
• return 0;
• }
Structure
• The structure is a user-defined data type in C,
which is used to store a collection of different
kinds of data.
• The structure is something similar to an array;
the only difference is array is used to store the
same data types.
• struct keyword is used to declare the structure
in C.
• Variables inside the structure are
called members of the structure.
Syntax
• struct structureName
• {
• //member definitions
• };
• Example
• struct Courses
• {
• char WebSite[50];
• char Subject[50];
• int Price;
• };
Example
• #include<stdio.h>
• #include<string.h>
• struct Courses { char WebSite[50];
• char Subject[50];
• int Price;
• };
• void main( )
• {
• struct Courses C;
• //Initialization strcpy( C.WebSite, "w3schools.in");
• strcpy( C.Subject, "The C Programming Language");
• C.Price = 0;
• //Print printf( "WebSite : %sn", C.WebSite);
• printf( "Book Author : %sn", C.Subject);
• printf( "Book Price : %dn", C.Price);
• }
Unions
• Unions are user-defined data type in C, which is
used to store a collection of different kinds of data,
just like a structure.
• However, with unions, you can only store
information in one field at any one time.
• Unions are like structures except it used less
memory.
• The keyword union is used to declare the structure
in C.
• Variables inside the union are called members of
the union.
Syntax
• union unionName
• {
• //member definitions
• };
• Example
• union Courses
• {
• char WebSite[50];
• char Subject[50];
• int Price;
• };
Thank you

More Related Content

What's hot

C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001Ralph Weber
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basicsLovelitJose
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput Ahmad Idrees
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructsGopikaS12
 
Overview of c language
Overview of c languageOverview of c language
Overview of c languageshalini392
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++Jaspal Singh
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSBESTECH SOLUTIONS
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c languagetanmaymodi4
 
Managing I/O operations In C- Language
Managing I/O operations In C- LanguageManaging I/O operations In C- Language
Managing I/O operations In C- LanguageRavindraSalunke3
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c languagetanmaymodi4
 
07 control+structures
07 control+structures07 control+structures
07 control+structuresbaran19901990
 

What's hot (18)

C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructs
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++
 
C program compiler presentation
C program compiler presentationC program compiler presentation
C program compiler presentation
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Managing I/O operations In C- Language
Managing I/O operations In C- LanguageManaging I/O operations In C- Language
Managing I/O operations In C- Language
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 

Similar to C programming language tutorial

Similar to C programming language tutorial (20)

C language
C languageC language
C language
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 
C
CC
C
 
Aspdot
AspdotAspdot
Aspdot
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
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
C programming languageC programming language
C programming language
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 

More from SURBHI SAROHA

Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2SURBHI SAROHA
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptxSURBHI SAROHA
 
Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)SURBHI SAROHA
 
Management Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxManagement Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxSURBHI SAROHA
 
Introduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxIntroduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxSURBHI SAROHA
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 

More from SURBHI SAROHA (20)

Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptx
 
Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)
 
Management Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxManagement Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptx
 
Introduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxIntroduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptx
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
DBMS (UNIT 5)
DBMS (UNIT 5)DBMS (UNIT 5)
DBMS (UNIT 5)
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 
JAVA(UNIT 4)
JAVA(UNIT 4)JAVA(UNIT 4)
JAVA(UNIT 4)
 
OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)
 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
 
DBMS UNIT 3
DBMS UNIT 3DBMS UNIT 3
DBMS UNIT 3
 
JAVA (UNIT 3)
JAVA (UNIT 3)JAVA (UNIT 3)
JAVA (UNIT 3)
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
 
DBMS (UNIT 2)
DBMS (UNIT 2)DBMS (UNIT 2)
DBMS (UNIT 2)
 
JAVA UNIT 2
JAVA UNIT 2JAVA UNIT 2
JAVA UNIT 2
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

C programming language tutorial

  • 1. C Programming Language Tutorial BY: SURBHI SAROHA
  • 2. C language • The C Language is developed by Dennis Ritchie for creating system applications that directly interact with the hardware devices such as drivers, kernels, etc. • C programming is considered as the base for other programming languages, that is why it is known as mother language.
  • 3. Why to Learn C Programming? • C programming language is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain. I will list down some of the key advantages of learning C Programming: • Easy to learn • Structured language • It produces efficient programs • It can handle low-level activities • It can be compiled on a variety of computer platforms
  • 4. C Supports Six Types of Tokens: • Identifiers • Keywords • Constants • Strings • Operators • Special Symbols
  • 5. C Keyword List • A list of 32 reserved keywords in c language is given below:
  • 6. Constants • Constants are like a variable, except that their value never changes during execution once defined. • Constants are also called literals. • Constants can be any of the data types. • It is considered best practice to define constants using only upper-case names.
  • 7. Example • #include<stdio.h> • main() • { • const int SIDE = 10; • int area; • area = SIDE*SIDE; • printf("The area of the square with side: %d is: %d sq. units" , SIDE, area); • }
  • 8. C operators • C operators are symbols that are used to perform mathematical or logical manipulations. The C programming language is rich with built-in operators. • Operators take part in a program for manipulating data and variables and form a part of the mathematical or logical expressions.
  • 9. Cont.... • C programming language offers various types of operators having different functioning capabilities. • Arithmetic Operators • Relational Operators • Logical Operators • Assignment Operators • Increment and Decrement Operators • Conditional Operator • Bitwise Operators • Special Operators
  • 10. Arithmetic Operators • Arithmetic Operators are used to performing mathematical calculations like addition (+), subtraction (-), multiplication (*), division (/) and modulus (%). • #include <stdio.h> • void main() • { • int i=3,j=7,k; • /* Variables Defining and Assign values */ • k=i+j; • printf("sum of two numbers is %dn", k); • }
  • 11. Increment and Decrement Operators • Increment and Decrement Operators are useful operators generally used to minimize the calculation, i.e. ++x and x++ means x=x+1 or -x and x−−means x=x-1. • But there is a slight difference between ++ or −− written before or after the operand. • Applying the pre-increment first add one to the operand and then the result is assigned to the variable on the left whereas post-increment first assigns the value to the variable on the left and then increment the operand
  • 12. Relational operators • Relational operators are used to comparing two quantities or values.
  • 13. Logical operators • C provides three logical operators when we test more than one condition to make decisions. These are: && (meaning logical AND), || (meaning logical OR) and ! (meaning logical NOT).
  • 14. Bitwise operator • C provides a special operator for bit operation between two variables.
  • 15. Assignment operators • Assignment operators applied to assign the result of an expression to a variable. C has a collection of shorthand assignment operators.
  • 16. Conditional operator • C offers a ternary operator which is the conditional operator (?: in combination) to construct conditional expressions. • C supports some special operators
  • 17. Data types • C provides three types of data types: • Primary(Built-in) Data Types: void, int, char, double and float. • Derived Data Types: Array, References, and Pointers. • User Defined Data Types: Structure, Union, and Enumeration.
  • 18. What is Loop? • A computer is the most suitable machine for performing repetitive tasks, and it can perform a task thousands of times. • Every programming language has the feature to instruct to do such repetitive tasks with the help of certain statements. • The process of repeatedly executing a collection of statements is called looping. • The statements get executed many numbers of times based on the condition. • But if the condition is given in such logic that the repetition continues any number of times with no fixed condition to stop looping those statements, then this type of looping is called infinite looping.
  • 19. Cont.... • C supports the following types of loops: • while loops • do-while loops • for loops • while loop • It is a most basic loop in C programming. while loop has one control condition, and executes as long the condition is true. • The condition of the loop is tested before the body of the loop is executed, hence it is called an entry- controlled loop.
  • 20. The basic format of while loop statement is: • Syntax: • While (condition) • { • statement(s); • Incrementation; • }
  • 21. Example • #include<stdio.h> • int main () • { /* local variable Initialization */ • int n = 1,times=5; • /* while loops execution */ • while( n <= times ) • { • printf("C while loops: %dn", n); • n++; • } • return 0; • }
  • 22. do while loops • C do while loops are very similar to the while loops, but it always executes the code block at least once and furthermore as long as the condition remains true. This is an exit- controlled loop. • do • { • statement(s); • }while( condition );
  • 23. Example • #include<stdio.h> • int main () • { /* local variable Initialization */ • int n = 1,times=5; • /* do loops execution */ • do • { • printf("C do while loops: %dn", n); • n = n + 1; • }while( n <= times ); • return 0; • }
  • 24. for loop • C for loops is very similar to a while loops in that it continues to process a block of code until a statement becomes false, and everything is defined in a single line. • The for loop is also entry-controlled loop. • for ( init; condition; increment ) • { • statement(s); • }
  • 25. Example • #include<stdio.h> • int main () • { /* local variable Initialization */ • int n,times=5; • /* for loops execution */ • for( n = 1; n <= times; n = n + 1 ) • { • printf("C for loops: %dn", n); • } • return 0; • }
  • 26. Structure • The structure is a user-defined data type in C, which is used to store a collection of different kinds of data. • The structure is something similar to an array; the only difference is array is used to store the same data types. • struct keyword is used to declare the structure in C. • Variables inside the structure are called members of the structure.
  • 27. Syntax • struct structureName • { • //member definitions • }; • Example • struct Courses • { • char WebSite[50]; • char Subject[50]; • int Price; • };
  • 28. Example • #include<stdio.h> • #include<string.h> • struct Courses { char WebSite[50]; • char Subject[50]; • int Price; • }; • void main( ) • { • struct Courses C; • //Initialization strcpy( C.WebSite, "w3schools.in"); • strcpy( C.Subject, "The C Programming Language"); • C.Price = 0; • //Print printf( "WebSite : %sn", C.WebSite); • printf( "Book Author : %sn", C.Subject); • printf( "Book Price : %dn", C.Price); • }
  • 29. Unions • Unions are user-defined data type in C, which is used to store a collection of different kinds of data, just like a structure. • However, with unions, you can only store information in one field at any one time. • Unions are like structures except it used less memory. • The keyword union is used to declare the structure in C. • Variables inside the union are called members of the union.
  • 30. Syntax • union unionName • { • //member definitions • }; • Example • union Courses • { • char WebSite[50]; • char Subject[50]; • int Price; • };