SlideShare a Scribd company logo
Basics of C Programming
R.SANDHIYA,
AP/CIT
DERIVED DATA TYPE
• Array:
collection of similar data-type
• Pointer:
C Pointer is a special variable that can be used to store
address of another variable.
2
ENUMERATED DATA TYPE (ENUM)
▪ user defined data type having finite set of
enumeration constants.
▪ keyword used 'enum'
▪ Enumeration data type -named integer constants
as a list.
▪ starts with 0 (zero) by default and value is
incremented by 1 for the sequential identifiers in the
list. 3
▪ Syntax:
Enum [datatype] {const1, const2… constn};
▪ Example:
enum month { Jan, Feb, Mar };
▪ /* Jan, Feb and Mar variables will be assigned to 0, 1
and 2 respectivelyby default */
4
enum month { Jan = 1, Feb, Mar };
▪ /* Feb and Mar variables will be assigned to 2 and 3
respectively by default */
enum month { Jan = 20, Feb, Mar };
▪ /* Jan is assigned to 20. Feb and Mar variables will
be assigned to 21 and 22 respectively by default */
5
TYPEDEF DATA TYPE
 It is used to create new data type.
 commonly used to change existing datatype with
another name.
 Syntax:
typedef [datatype] newdatatype;
 Example:
typedef int integer;
integer rollno;
6
STRUCTURE DATA TYPE
 collection of different data types which are grouped
together
 each element in a C structure is called member.
7
 Example:
struct student
{
int rollno;
Char name[20];
Char city[20];
}
8
Declaring a variable as constant
Eg: const int classsize = 40;
 This tells the compiler that the value of the int
variable classsize must not be modified by the
program.
9
Declaring a variable as volatile
 By declaring a variable as volatile, its value may be
changed at any time by some external source.
 Eg: volatile int date;
10
OPERATORS OF C
• C supports a rich set of operators.
• Operators are used in programs to manipulate data and
variables.
• forms a part of the mathematical of logical expressions.
• Categories.
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and Decrement operators
6. Conditional operators
7. Bitwise operators
8. Special operators
ARITHMETIC OPERATORS
Eg: 1) a-b 2) a+b 3) a*b 4) p%q
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
Integer Arithmetic
 When both the operands in a single arithmetic expression are integers,
the expression is called an integer expression , and the operation is
called integer arithmetic.
 During modulo division the sign of the result is always the sign of the first
operand.
-14 % 3 = -2
-14 % -3 = -2
14 % -3 = 2
Real Arithmetic
• An arithmetic operation involving only real operands
is called real arithmetic.
• If x and y are floats then we will have:
1) x = 6.0 / 7.0 = 0.857143
2) y = 1.0 / 3.0 = 0.333333
 The operator % cannot be used with real operands
Mixed-mode Arithmetic
 When one of the operands is real and the other is
integer, the expression is called a mixed-mode
arithmetic expression and its result is always a real
number.
eg: 1) 15 / 10.0 = 1.5
RELATIONAL OPERATORS
• Comparisons can be done with the help of
relational operators.
• The expression containing a relational operator
is termed as a relational expression.
• The value of a relational expression is either one
or zero
Operator Meaning
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to
RELATIONAL OPERATORS
LOGICAL OPERATORS
• C has the following three logical operators.
OPERATOR DESCRIPTION EXAMPLE
&& AND X=9,Y=8
X<10 && Y >0
Returns TRUE
|| OR x=9, y=x==5 || y == 5
! NOT
19
Thanks!
You can find me at:
▪ rsandhiya@cit.edu.in

More Related Content

PPT
Arithmetic operator
PPTX
PPTX
Basic c operators
PDF
Operators in c programming
PDF
Conditional operators
 
PPTX
Python operators
PDF
Chapter 5 - Operators in C++
PPTX
ppt on logical/arthimatical/conditional operators
Arithmetic operator
Basic c operators
Operators in c programming
Conditional operators
 
Python operators
Chapter 5 - Operators in C++
ppt on logical/arthimatical/conditional operators

What's hot (20)

PPTX
C OPERATOR
PPTX
Operators in c++
ODP
Operators
PPT
Operators in c language
PPTX
C Operators
PPT
Types of operators in C
PPTX
COM1407: C Operators
PPTX
Operators and expressions
PPT
C operator and expression
PPTX
Operator in c programming
PPT
Operation and expression in c++
PPT
6 operators-in-c
PPTX
Operators in C/C++
DOC
Report on c
DOCX
C – operators and expressions
PPTX
Operator of C language
PPTX
Operators in C & C++ Language
PPTX
PPT
CBSE Class XI :- Operators in C++
PPT
2. operators in c
C OPERATOR
Operators in c++
Operators
Operators in c language
C Operators
Types of operators in C
COM1407: C Operators
Operators and expressions
C operator and expression
Operator in c programming
Operation and expression in c++
6 operators-in-c
Operators in C/C++
Report on c
C – operators and expressions
Operator of C language
Operators in C & C++ Language
CBSE Class XI :- Operators in C++
2. operators in c
Ad

Similar to Basics of c programming cit r.sandhiya (20)

PPTX
Class 2 variables, classes methods...
PPTX
Operators in C Programming
PDF
Types of Operators in C
PDF
Unit ii chapter 1 operator and expressions in c
PPTX
operatorsincprogramming-190221094522.pptx
PPTX
Operators1.pptx
PPT
Token and operators
PPTX
Fundamentals of computers - C Programming
PPTX
C PRESENTATION.pptx
PDF
Lamborghini Veneno Allegheri #2004@f**ck
PPTX
COM1407: Working with Pointers
PPTX
data type.pptxddddswwyertr hai na ki extend kr de la
PPTX
OPERATORS OF C++
PDF
02 - Data Types and Expressions using C.pdf
PPTX
C++ revision add on till now
PPTX
C++ revision add on till now
PPTX
Chapter 3.3
PPTX
C Language Part 1
PPTX
C sharp part 001
PPTX
Unit 2- Control Structures in C programming.pptx
Class 2 variables, classes methods...
Operators in C Programming
Types of Operators in C
Unit ii chapter 1 operator and expressions in c
operatorsincprogramming-190221094522.pptx
Operators1.pptx
Token and operators
Fundamentals of computers - C Programming
C PRESENTATION.pptx
Lamborghini Veneno Allegheri #2004@f**ck
COM1407: Working with Pointers
data type.pptxddddswwyertr hai na ki extend kr de la
OPERATORS OF C++
02 - Data Types and Expressions using C.pdf
C++ revision add on till now
C++ revision add on till now
Chapter 3.3
C Language Part 1
C sharp part 001
Unit 2- Control Structures in C programming.pptx
Ad

Recently uploaded (20)

DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
DOCX
573137875-Attendance-Management-System-original
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
additive manufacturing of ss316l using mig welding
PDF
Digital Logic Computer Design lecture notes
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Geodesy 1.pptx...............................................
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
573137875-Attendance-Management-System-original
Foundation to blockchain - A guide to Blockchain Tech
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
Sustainable Sites - Green Building Construction
additive manufacturing of ss316l using mig welding
Digital Logic Computer Design lecture notes
Structs to JSON How Go Powers REST APIs.pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
OOP with Java - Java Introduction (Basics)
Geodesy 1.pptx...............................................
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Lesson 3_Tessellation.pptx finite Mathematics

Basics of c programming cit r.sandhiya

  • 1. Basics of C Programming R.SANDHIYA, AP/CIT
  • 2. DERIVED DATA TYPE • Array: collection of similar data-type • Pointer: C Pointer is a special variable that can be used to store address of another variable. 2
  • 3. ENUMERATED DATA TYPE (ENUM) ▪ user defined data type having finite set of enumeration constants. ▪ keyword used 'enum' ▪ Enumeration data type -named integer constants as a list. ▪ starts with 0 (zero) by default and value is incremented by 1 for the sequential identifiers in the list. 3
  • 4. ▪ Syntax: Enum [datatype] {const1, const2… constn}; ▪ Example: enum month { Jan, Feb, Mar }; ▪ /* Jan, Feb and Mar variables will be assigned to 0, 1 and 2 respectivelyby default */ 4
  • 5. enum month { Jan = 1, Feb, Mar }; ▪ /* Feb and Mar variables will be assigned to 2 and 3 respectively by default */ enum month { Jan = 20, Feb, Mar }; ▪ /* Jan is assigned to 20. Feb and Mar variables will be assigned to 21 and 22 respectively by default */ 5
  • 6. TYPEDEF DATA TYPE  It is used to create new data type.  commonly used to change existing datatype with another name.  Syntax: typedef [datatype] newdatatype;  Example: typedef int integer; integer rollno; 6
  • 7. STRUCTURE DATA TYPE  collection of different data types which are grouped together  each element in a C structure is called member. 7
  • 8.  Example: struct student { int rollno; Char name[20]; Char city[20]; } 8
  • 9. Declaring a variable as constant Eg: const int classsize = 40;  This tells the compiler that the value of the int variable classsize must not be modified by the program. 9
  • 10. Declaring a variable as volatile  By declaring a variable as volatile, its value may be changed at any time by some external source.  Eg: volatile int date; 10
  • 11. OPERATORS OF C • C supports a rich set of operators. • Operators are used in programs to manipulate data and variables. • forms a part of the mathematical of logical expressions. • Categories. 1. Arithmetic operators 2. Relational operators 3. Logical operators 4. Assignment operators 5. Increment and Decrement operators 6. Conditional operators 7. Bitwise operators 8. Special operators
  • 12. ARITHMETIC OPERATORS Eg: 1) a-b 2) a+b 3) a*b 4) p%q + Addition - Subtraction * Multiplication / Division % Modulo
  • 13. Integer Arithmetic  When both the operands in a single arithmetic expression are integers, the expression is called an integer expression , and the operation is called integer arithmetic.  During modulo division the sign of the result is always the sign of the first operand. -14 % 3 = -2 -14 % -3 = -2 14 % -3 = 2
  • 14. Real Arithmetic • An arithmetic operation involving only real operands is called real arithmetic. • If x and y are floats then we will have: 1) x = 6.0 / 7.0 = 0.857143 2) y = 1.0 / 3.0 = 0.333333  The operator % cannot be used with real operands
  • 15. Mixed-mode Arithmetic  When one of the operands is real and the other is integer, the expression is called a mixed-mode arithmetic expression and its result is always a real number. eg: 1) 15 / 10.0 = 1.5
  • 16. RELATIONAL OPERATORS • Comparisons can be done with the help of relational operators. • The expression containing a relational operator is termed as a relational expression. • The value of a relational expression is either one or zero
  • 17. Operator Meaning < Less than <= Less than or equal to > Greater than >= Greater than or equal to == Equal to != Not equal to RELATIONAL OPERATORS
  • 18. LOGICAL OPERATORS • C has the following three logical operators. OPERATOR DESCRIPTION EXAMPLE && AND X=9,Y=8 X<10 && Y >0 Returns TRUE || OR x=9, y=x==5 || y == 5 ! NOT