SlideShare a Scribd company logo
Basics of ‘C’
Programming
Presented By: Shamsul Husain Ansari
G. H. Raisoni Institute of Engineering & Technology, Nagpur
What is ‘C’?
C is a Procedure Oriented Programming language use for Game design,
Graphics, Enterprise Applications.
C is widely used language. It provides many features that are given below.
● Machine Independent
● High Speed
● Pointers
● Recursion
Header Files : Header files in C language Contains the set of predefined standard
library functions.
● #include<stdio.h> : It is used for perform input and output operations using
functions scanf() and printf().
● #include<math.h>: It is used to perform mathematical operations like sqrt(),
pow(), etc.
● #include<time.h>: It is used to perform functions related to date() and time().
● #include<fstream.h>: It is used to control the data to read from a file as an
input and data to write into the file as an output
● Example : #include<stdio.h>
Header files in ‘C’.
What is main in ‘C’.
A main is a predefined keyword or function in C. It is a special function that always starts
executing code from the ‘main’ having ‘int’ or ‘void’ as return data type. In other words, a main()
function is an entry point of the programming code to start its execution.
Syntax:
int main() {
//body of the code
return 0;
}
Basic Structure of C Program
Header file #include<stdio.h>
main function int main() {
Variable declaration int a=20;
Body printf(“The value of a is %d”,a);
return return 0;
}
Keywords & Identifiers in ‘C’
In C language identifiers are the names given to variables, constants, functions and user-
defined data.
Syntax : data_type variable_name;
Examples: int marks; //in Ram the 2 byte of memory allocate by the name of marks.
Keyword Identifier
Int
float
char
number
decimal
character
Data Types in ‘C'
C has various data types to store data in program. C program can store integer,
decimal number, character(alphabets), string(word or sentence), list etc.
Syntax : type variable_name;
Example1: int roll_no; // int used for storing integer value.
Example 2: float percentage; // float data type used for storing decimal
numbers.
Note: C is a case sensitive language. It matter whether an identifier such as variable
name, is UPPERCASE or lowercase.
Keyword Used Format Specifier Size (Bytes)
int “%d” 4
char “%c” 1
float “%f” 4
double “%lf” 8
The format specifiers are used in C for input and output purposes. Using this concept the compiler
can understand that what type of data is in a variable during taking input using scanf() function and
printing using printf() function.
C Input
In C programming, scanf() is one of the commonly used function to take input from the user.
The scanf() function read formatted input from the standard input such as keyboards.
Example:
#include<stdio.h>
int main() {
int age; // variable declaration of type integer.
char name[7];
scanf(“%d”, &age);
scanf(“%s”,name);
printf(“Age= %d”, age); // printf() function used to display the output to
the user.
return 0;
}
Note: & represent the memory address and &age denotes the memory address of age.
Operators in C
An operator is simply a symbol that is used to perform operations. There can be many type of
operations like arithmetic, logical, bitwise, etc.
Arithmetic Operator: An arithmetic operator perform mathematical operation such as addition,
subtraction, multiplication, division etc on numerical values.
Operator Meaning of Operator
+ Addition
- subtraction
* multiplication
/ division
& remainder after division (modulo division)
Example
#include<stdio.h>
int main() {
Int a = 6, b = 4, c;
c = a+b;
printf(“ADDITION: %d”,c);
c = a-b;
printf(“SUBTRACTION: %d”, c);
return 0;
}
Output: ADDITION: 10
SUBTRACTION: 2
Increment & Decrement Operators
C programming has two operator increment ++ and decrement - - to change the
value of an operand (constant or variable) by 1.
Operator Meaning of Operator
++ Increment the value by 1
– – Decrement the value by 1
#include<stdio.h>
int main() {
int a = 10, b = 5;
printf(“INCREMENT: %d”,++a);
printf(“DECREMENT: %d”, - - b );
return 0;
}
Relational Operators
A relational operator checks the relationship between two operands. If the relation
is true, it returns 1; if the relation is false, it return value 0.
Operator Meaning of Operator Example
== Equal to 5 == 3 return 0
> Greater than 5 > 3 return 1
< Less than 5 < 3 return 0
!= Not equal to 5!=3 return 1
>= Greater than or equal to 5>=3 return 1
<= Less than or equal to 5<=3 return 0
Example
#include<stdio.h>
int main() {
Int a = 5, b = 3;
printf(“Equal to: %d”, a==b);
printf(“Not Equal: %d”, a!=b);
return 0;
}
Output: Equal to: 0
Not Equal : 1
Logical Operators
An expression containing logical operator returns either 0 or 1 depending upon
whether expression results true or false. Logical operators are commonly used in
decision making in C Programming
Operator Meaning
&& Logical AND. True only if all the operand
are true.
|| Logical OR. True only if either one operand
is true.
! Logical NOT. Only if the operand is 0
Example
#include<stdio.h>
int main() {
int a = 5, b = 5, c=10, result;
result = (a == b) && (c > b);
printf("%dn", result);
result = (a != b) || (c > b);
printf("%dn", result);
result = !(a == b);
printf("%dn", result);
return 0;
}
Exercise
Char type
Integer type
Float type
Solution

More Related Content

Similar to Basic of C Programming | 2022 Updated | By Shamsul H. Ansari

2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
Don Dooley
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
RohitRaj744272
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
REHAN IJAZ
 
C programming
C programmingC programming
C programming
PralhadKhanal1
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notesSrikanth
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
JAYA
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
Pradipta Mishra
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
Pradipta Mishra
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
Mehul Desai
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
trupti1976
 
Programming in c
Programming in cProgramming in c
Programming in c
Ashutosh Srivasatava
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
Mahira Banu
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
Likhil181
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
KrishanPalSingh39
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
SURBHI SAROHA
 

Similar to Basic of C Programming | 2022 Updated | By Shamsul H. Ansari (20)

2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
C programming
C programmingC programming
C programming
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
C programming
C programmingC programming
C programming
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 

Recently uploaded

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 

Recently uploaded (20)

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 

Basic of C Programming | 2022 Updated | By Shamsul H. Ansari

  • 1. Basics of ‘C’ Programming Presented By: Shamsul Husain Ansari G. H. Raisoni Institute of Engineering & Technology, Nagpur
  • 2. What is ‘C’? C is a Procedure Oriented Programming language use for Game design, Graphics, Enterprise Applications. C is widely used language. It provides many features that are given below. ● Machine Independent ● High Speed ● Pointers ● Recursion
  • 3. Header Files : Header files in C language Contains the set of predefined standard library functions. ● #include<stdio.h> : It is used for perform input and output operations using functions scanf() and printf(). ● #include<math.h>: It is used to perform mathematical operations like sqrt(), pow(), etc. ● #include<time.h>: It is used to perform functions related to date() and time(). ● #include<fstream.h>: It is used to control the data to read from a file as an input and data to write into the file as an output ● Example : #include<stdio.h> Header files in ‘C’.
  • 4. What is main in ‘C’. A main is a predefined keyword or function in C. It is a special function that always starts executing code from the ‘main’ having ‘int’ or ‘void’ as return data type. In other words, a main() function is an entry point of the programming code to start its execution. Syntax: int main() { //body of the code return 0; }
  • 5. Basic Structure of C Program Header file #include<stdio.h> main function int main() { Variable declaration int a=20; Body printf(“The value of a is %d”,a); return return 0; }
  • 6. Keywords & Identifiers in ‘C’ In C language identifiers are the names given to variables, constants, functions and user- defined data. Syntax : data_type variable_name; Examples: int marks; //in Ram the 2 byte of memory allocate by the name of marks. Keyword Identifier Int float char number decimal character
  • 7. Data Types in ‘C' C has various data types to store data in program. C program can store integer, decimal number, character(alphabets), string(word or sentence), list etc. Syntax : type variable_name; Example1: int roll_no; // int used for storing integer value. Example 2: float percentage; // float data type used for storing decimal numbers. Note: C is a case sensitive language. It matter whether an identifier such as variable name, is UPPERCASE or lowercase.
  • 8. Keyword Used Format Specifier Size (Bytes) int “%d” 4 char “%c” 1 float “%f” 4 double “%lf” 8 The format specifiers are used in C for input and output purposes. Using this concept the compiler can understand that what type of data is in a variable during taking input using scanf() function and printing using printf() function.
  • 9. C Input In C programming, scanf() is one of the commonly used function to take input from the user. The scanf() function read formatted input from the standard input such as keyboards. Example: #include<stdio.h> int main() { int age; // variable declaration of type integer. char name[7]; scanf(“%d”, &age); scanf(“%s”,name); printf(“Age= %d”, age); // printf() function used to display the output to the user. return 0; } Note: & represent the memory address and &age denotes the memory address of age.
  • 10. Operators in C An operator is simply a symbol that is used to perform operations. There can be many type of operations like arithmetic, logical, bitwise, etc. Arithmetic Operator: An arithmetic operator perform mathematical operation such as addition, subtraction, multiplication, division etc on numerical values. Operator Meaning of Operator + Addition - subtraction * multiplication / division & remainder after division (modulo division)
  • 11. Example #include<stdio.h> int main() { Int a = 6, b = 4, c; c = a+b; printf(“ADDITION: %d”,c); c = a-b; printf(“SUBTRACTION: %d”, c); return 0; } Output: ADDITION: 10 SUBTRACTION: 2
  • 12. Increment & Decrement Operators C programming has two operator increment ++ and decrement - - to change the value of an operand (constant or variable) by 1. Operator Meaning of Operator ++ Increment the value by 1 – – Decrement the value by 1 #include<stdio.h> int main() { int a = 10, b = 5; printf(“INCREMENT: %d”,++a); printf(“DECREMENT: %d”, - - b ); return 0; }
  • 13. Relational Operators A relational operator checks the relationship between two operands. If the relation is true, it returns 1; if the relation is false, it return value 0. Operator Meaning of Operator Example == Equal to 5 == 3 return 0 > Greater than 5 > 3 return 1 < Less than 5 < 3 return 0 != Not equal to 5!=3 return 1 >= Greater than or equal to 5>=3 return 1 <= Less than or equal to 5<=3 return 0
  • 14. Example #include<stdio.h> int main() { Int a = 5, b = 3; printf(“Equal to: %d”, a==b); printf(“Not Equal: %d”, a!=b); return 0; } Output: Equal to: 0 Not Equal : 1
  • 15. Logical Operators An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false. Logical operators are commonly used in decision making in C Programming Operator Meaning && Logical AND. True only if all the operand are true. || Logical OR. True only if either one operand is true. ! Logical NOT. Only if the operand is 0
  • 16. Example #include<stdio.h> int main() { int a = 5, b = 5, c=10, result; result = (a == b) && (c > b); printf("%dn", result); result = (a != b) || (c > b); printf("%dn", result); result = !(a == b); printf("%dn", result); return 0; }