SlideShare a Scribd company logo
1 of 19
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

What's hot

Operators in c language
Operators in c languageOperators in c language
Operators in c language
Amit Singh
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
vishaljot_kaur
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++
Pranav Ghildiyal
 

What's hot (20)

C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
 
Operators in c++
Operators in c++Operators in c++
Operators in c++
 
Operators
OperatorsOperators
Operators
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
C Operators
C OperatorsC Operators
C Operators
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
Report on c
Report on cReport on c
Report on c
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Operator of C language
Operator of C languageOperator of C language
Operator of C language
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Operators
OperatorsOperators
Operators
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
 

Similar to Basics of c programming cit r.sandhiya

data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
sotlsoc
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
AnisZahirahAzman
 

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

Class 2 variables, classes methods...
Class 2   variables, classes methods...Class 2   variables, classes methods...
Class 2 variables, classes methods...
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.pptx
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ck
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
5 conceptos progamacion2-tema4
5 conceptos progamacion2-tema45 conceptos progamacion2-tema4
5 conceptos progamacion2-tema4
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 
C program
C programC program
C program
 
C language
C languageC language
C language
 

Recently uploaded

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Recently uploaded (20)

Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 

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
  • 19. 19 Thanks! You can find me at: ▪ rsandhiya@cit.edu.in