SlideShare a Scribd company logo
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 001
Ralph Weber
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose
 
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 constructs
GopikaS12
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
shalini392
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++
Jaspal Singh
 
C program compiler presentation
C program compiler presentationC program compiler presentation
C program compiler presentation
Rigvendra Kumar Vardhan
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
BESTECH SOLUTIONS
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
tanmaymodi4
 
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
RavindraSalunke3
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
tanmaymodi4
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
sunila tharagaturi
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
Thooyavan Venkatachalam
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
baran19901990
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
Michael Heron
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
Ashim Lamichhane
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
Appili Vamsi Krishna
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
Ashim Lamichhane
 

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

C language
C languageC language
C language
Mukul Kirti Verma
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
Janani Satheshkumar
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
Mangala R
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
Steve Johnson
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
Abdullah Jan
 
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
GOKULKANNANMMECLECTC
 
C
CC
Aspdot
AspdotAspdot
Programming Language
Programming  LanguageProgramming  Language
Programming Language
Adeel Hamid
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
sophoeutsen2
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
8759000398
 
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
Vigneshkumar Ponnusamy
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
MohammedtajuddinTaju
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
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
Dr.Florence Dayana
 
C programming language
C programming languageC programming language
C programming language
Abin Rimal
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C language unit-1
C language unit-1C 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
Malikireddy Bramhananda Reddy
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
Gilbert NZABONITEGEKA
 

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
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_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 2
SURBHI SAROHA
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptx
SURBHI 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).pptx
SURBHI 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).pptx
SURBHI SAROHA
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
SURBHI SAROHA
 
DBMS (UNIT 5)
DBMS (UNIT 5)DBMS (UNIT 5)
DBMS (UNIT 5)
SURBHI SAROHA
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
SURBHI SAROHA
 
JAVA(UNIT 4)
JAVA(UNIT 4)JAVA(UNIT 4)
JAVA(UNIT 4)
SURBHI SAROHA
 
OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)
SURBHI SAROHA
 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
SURBHI SAROHA
 
DBMS UNIT 3
DBMS UNIT 3DBMS UNIT 3
DBMS UNIT 3
SURBHI SAROHA
 
JAVA (UNIT 3)
JAVA (UNIT 3)JAVA (UNIT 3)
JAVA (UNIT 3)
SURBHI SAROHA
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
SURBHI SAROHA
 
DBMS (UNIT 2)
DBMS (UNIT 2)DBMS (UNIT 2)
DBMS (UNIT 2)
SURBHI SAROHA
 
JAVA UNIT 2
JAVA UNIT 2JAVA UNIT 2
JAVA 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 1
SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
SURBHI SAROHA
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
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

Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 

Recently uploaded (20)

Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 

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; • };