SlideShare a Scribd company logo
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
UNIT-II
C PROGRAMMING BASICS
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
CHARACTER SET
C CHARACTER SET
Execution Character
Set
Source Character Set
DigitsAlphabets Special Character
White
Space
Character
Space
Escape
Sequence
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
A Character denotes an alphabet, digit or a
special character.
Lowercase Letters – A,B,C….. Z
Uppercase Letters - a,b,c…… z
Digits – 0,1,2,3,…7,8,9
+ Plus Sign - Minus Sign , Comma
* Asterisk / Slash = Equal to
@ At Symbol < Less Than : Colon
; Semicolon
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
It will work at the execution time only and it cannot be printed.
It always represented by a backslash() followed by a character.
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
 The smallest individual units of a c program are
known as tokens
 It can be categorized into following ways
C tokens
operators
Special
symbolstringconstantsIdentifiersKeywords
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
 Keyword is a reserved keyword that has a particular meaning
 It should be in lower case
 There are 32 keywords in c language
S.
NO
keyword S.
NO
keyword S.NO keyword S.
NO
keyword keyword
1 auto 8 do 15 goto 22 signed 29.unsigned
2 break 9 double 16 if 23 sizeof 30.void
3 case 10 else 17 int 24 static 31.volatile
4 char 11 enum 18 long 25 struct 32.while
5 const 12 extern 19 register 26 switch
6 continue 13 float 20 return 27 typedef
7 default 14 for 21 short 28 union
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
 It can be a variable name and function name etc.
 Maximum length of an identifier is 31
 Special character are not allowed except(_).
Valid invalid
nithiya Nithya#
NITHIYA Nith ya ->blank space
Nithya3 Auto
Nithya 3nithya
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
10
-356
4600.5
-0.963
‘A’
‘*’
“A”
“CSC”
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
Variables are named locations in memory that are used to
hold a value that may be modified by the program.
K5.ico ANIMATAY006.ICO
The syntax for declaring a variable is
Data type Variablename;
Valid Examples :
CSC avg_val
m1 Chennai Anu
mark_1
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
RULES for framing a variable :
The first character in the Variable name must be an alphabet
Alphabets can be followed by a number of digits or
underscores
No commas or Blank spaces are allowed within a variable
name
No Special character other than Underscore(_) can be used in
a variable name.
The variable name should not be a keyword
Variable names are case sensitive
It should not be of length more than 31 characters
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
INTIALIZING VARIABLE
Assigning some value to the variable is known as intialization
SYNTAX:
Data type variable name=value;
Example
Int a=10;
SCOPE OF VARIABLE
1.Local variable
2.Global variable
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
Scope of
variable
definition example
Local
variable
Declared
inside the
block
main()
{
Int a=8; // local
variable
}
Global
variable
Declared
before the
main function
Int a=8;
Main()
{
//no of statement
}
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
C data types
Empty data
type
User defined
data type
Derived or
secondary data
type
Primary data
type
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
PRIMARY DATA TYPES
int float chardouble
1.PRIMARY DATA TYPES
S.N
O
Data
Type
Explanation Size(bytes) CONTRO
L
STRING
RANGE SYNTAX EXAMPLE
1 int It store numeric values
without decimal point
Example:9,10,23
2 bytes %d or %i -32,768 to
+32,767
int
Variable_na
me;
int roll_no;
2 float It store the numeric
values with decimal
point
Example:3.12,47.098
4 bytes %f or %g 3.4E-38 to
3.4E+38
Float
Variable_na
me;
float a;
3 double It store the big number
of decimal point
Example:2.13455
8 bytes %if 1.7E-308 to
1.7E+308
Double
Variable
name;
double b;
4 char It store the single
character
Example:’a’,’9’
1 bytes %c -128 to +127 Char
Variable
name;
char
a=“nithiya”;
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
1.Array
An array is a collection of variable of same data type
SYNTAX: Datatype array_name[array size];
Example: int a[10];
2.Structures
it stores the multiple values of same or different data type
under a single name
Syntax:
Struct <struct name>
{
Member 1;member 2;};
DERIVED DATA
TYPE
array pointersunionsstructures
EXAMPLE:
Struct Student
{
Char name[10];
Int roll_no;
};
3.UNION
A union is store the multiple values of same or different data type
SYNTAX:
union <union name>
{
Member 1; member 2;
}
EXAMPLE:
Union student
{
Char name[25];
};
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
4.POINTERS
A pointer is holds the memory address of another variable
SYNTAX:
Data type *variable name
EXAMPLE : int *a
EMPTY DATA TYPE
i)Void
its represents an empty value
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
1.Type Definition
Example: Typedef int age;
age male,female
2.Enumerated Datatype
Example :
enum mon{jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec };
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
USER DEFINED DATA TYPE
Control
statement
conditional unconditional
selective looping
Nested if else
Simple if
If else
If-else if
ladder
Switch case
while
do while
for
goto
break
continue
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
 A program is a sequence of one or more instructions
 The condition will check whether the particular
condition are true (or) not.
 1.SIMPLE IF STATEMENT
 If the condition is true the set of statements are
executed
 SYNTAX

if(condition)
{
Statement 1;
}
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
To find the given no is even or odd
#include<stdio.h>
#include<conio.h>
main()
{
int no;
clrscr();
printf(“n Enter the number”);
scanf(“%d”,&no);
if(no%2==0)
{
printf(The given no is even”);
}}
Output
Enter the number
24
The given no is even
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
2.if else statement
It is a two way decision making statement
SYNTAX:
if(condition)
{
Statement 1;
}
else
{ false statement;
}
#include<stdio.h>
#include<conio.h>
main()
{
int no;
clrscr();
printf(“n Enter the number”);
scanf(“%d”,&no);
if(no%2==0)
{
printf(The given no is even”);
}
else
{
Printf(“The given no is odd”);
}
#include<stdio.h>
#include<conio.h>
main()
{
int no;
clrscr();
printf(“n Enter the number”);
scanf(“%d”,&no);
if(no%2==0)
{
printf(The given no is even”);
}
else
{
Printf(“The given no is odd”);
}
Output
Enter the number
25
The given no is odd
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
 The number of logical conditions is checked for executing various
statements
 SYNTAX
 if(condition 1)
 {
 True statement 1;
 }
 else
 {
 if(condition 2)
 {
 True statement 2;
 }
 else
 {
 False statement
}}
#include<stdio.h>
#include<conio.h>
Main()
{
int a,b,c;
clrscr();
printf(“Enter a,b,c”);
scanf(“%d%d%d”,&a,&b,&c);
if((a>b)&&(a>c))
{
printf(“A is greater”);
}
else
{
If(b>c)
{
printf(“B is greater”);
}
else
{
printf(“C is greater”);
}}}
Output
Enter the values of a,b,c
4
2
3
A is greater
Nested if-else can be chained with one another
Syntax:
if(condition 1)
{
Statement 1;
}
else if(condition 2);
{
Statement 2;
}
else if(condition 3)
{
statement;
}
else
{
Final statement
}
#include<stdio.h>
#include<conio.h>
Main()
{
int a,b,c;
clrscr();
printf(“Enter a,b,c”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
{
If(a>c)
{
printf(“A is greater”);
}
else
{
printf(“C is greater”);
} }
else if(b>c)
{
printf(“B is greater”);
}
else
{
printf(“C is greater”);
}}
Output
Enter the values of a,b,c
4
2
3
A is greater
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG
 If the value matches with case constant, this particular case statement is executed.
if not default is executed.
 SYNTAX:
 Switch (variable)
 {
 Case constant 1:
 statement 1;
 Break;
 Case constant 2:
 Statement 2;
 Break;
 ..
 ..
 default:
 Default statement;
 }
#include<stdio.h>
#include<conio.h>
Main()
{
int a=10,b=5;
char symbol;
clrscr();
printf(“Enter the symbol”);
scanf(“%c”,&symbol);
switch(symbol)
{
case’+’:
result=a+b;
break;
case’-’:
result=a-b;
break;
case’*’:
Result=a*b;
Break;
Case’/’:
Result=a/b;
break;
case’%’:
Result=a%b;
break;
}
Default:
Printf(“invalid symbol”);
}
Printf(“the result is %d”,result);
}
Output
Enter the symbol:+
The result is 15
Enter the symbol:%
The result is 0
PREPARED BY K,NITHIYA
AP/IT
ANNAI CLG OF ENGG

More Related Content

What's hot (19)

Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
Python Programming
Python ProgrammingPython Programming
Python Programming
Saravanan T.M
 
C language basics
C language basicsC language basics
C language basics
Milind Deshkar
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Moving Average Filter in C
Moving Average Filter in CMoving Average Filter in C
Moving Average Filter in C
Colin
 
C program compiler presentation
C program compiler presentationC program compiler presentation
C program compiler presentation
Rigvendra Kumar Vardhan
 
C Programming basics
C Programming basicsC Programming basics
C Programming basics
Jitin Pillai
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
Rai University
 
Basic Input and Output
Basic Input and OutputBasic Input and Output
Basic Input and Output
Nurul Zakiah Zamri Tan
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
Vikram Nandini
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c language
RavindraSalunke3
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Moving Average Filter in C
Moving Average Filter in CMoving Average Filter in C
Moving Average Filter in C
Colin
 
C Programming basics
C Programming basicsC Programming basics
C Programming basics
Jitin Pillai
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
Rai University
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c language
RavindraSalunke3
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 

Viewers also liked (20)

c++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data typesc++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data types
AAKASH KUMAR
 
Getec Industrial Turnkey Heat Sink Thermal Solution Division
Getec Industrial Turnkey Heat Sink Thermal Solution DivisionGetec Industrial Turnkey Heat Sink Thermal Solution Division
Getec Industrial Turnkey Heat Sink Thermal Solution Division
Getec Industrial
 
Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1
Ajay Chimmani
 
Resume testing
Resume  testingResume  testing
Resume testing
Neha KM
 
Schluchtensteig
SchluchtensteigSchluchtensteig
Schluchtensteig
pweiland
 
Building Envelope-Web2
Building Envelope-Web2Building Envelope-Web2
Building Envelope-Web2
Clare Mansbridge
 
Les points forts
Les points fortsLes points forts
Les points forts
Lubina Rampersand
 
презентація декади природничих наук
презентація декади природничих наукпрезентація декади природничих наук
презентація декади природничих наук
Тетянка Гайдаєнко-Сохан
 
Romanticismo
RomanticismoRomanticismo
Romanticismo
Karenciitha Bolaños
 
El vent
El vent  El vent
El vent
lborrasborras
 
תמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"א
תמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"אתמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"א
תמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"א
Aviram Seo
 
CE for spatz balloon אישור
CE for spatz balloon אישורCE for spatz balloon אישור
CE for spatz balloon אישור
Aviram Seo
 
TDC2016SP - Criando modelos em nuvem com Azure Machine Learning
TDC2016SP - Criando modelos em nuvem com Azure Machine LearningTDC2016SP - Criando modelos em nuvem com Azure Machine Learning
TDC2016SP - Criando modelos em nuvem com Azure Machine Learning
tdc-globalcode
 
TDC2016SP - SparkMLlib Machine Learning na Prática
TDC2016SP -  SparkMLlib Machine Learning na PráticaTDC2016SP -  SparkMLlib Machine Learning na Prática
TDC2016SP - SparkMLlib Machine Learning na Prática
tdc-globalcode
 
TDC2016SP - Colocando modelos de Machine Learning em produção.
TDC2016SP - Colocando modelos de Machine Learning em produção.TDC2016SP - Colocando modelos de Machine Learning em produção.
TDC2016SP - Colocando modelos de Machine Learning em produção.
tdc-globalcode
 
El circuit electric_1er_eso
El circuit electric_1er_esoEl circuit electric_1er_eso
El circuit electric_1er_eso
lborrasborras
 
William Giba Digital Resume/CV
William Giba Digital Resume/CVWilliam Giba Digital Resume/CV
William Giba Digital Resume/CV
William Giba
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
Java Programming
 
Teatro Valle-Inclán
Teatro Valle-InclánTeatro Valle-Inclán
Teatro Valle-Inclán
JorgeMartinezBarcia
 
c++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data typesc++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data types
AAKASH KUMAR
 
Getec Industrial Turnkey Heat Sink Thermal Solution Division
Getec Industrial Turnkey Heat Sink Thermal Solution DivisionGetec Industrial Turnkey Heat Sink Thermal Solution Division
Getec Industrial Turnkey Heat Sink Thermal Solution Division
Getec Industrial
 
Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1
Ajay Chimmani
 
Resume testing
Resume  testingResume  testing
Resume testing
Neha KM
 
Schluchtensteig
SchluchtensteigSchluchtensteig
Schluchtensteig
pweiland
 
תמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"א
תמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"אתמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"א
תמ"א 35/1/ב: ישובים כפריים הכלולים בלוח 2 בתמ"א
Aviram Seo
 
CE for spatz balloon אישור
CE for spatz balloon אישורCE for spatz balloon אישור
CE for spatz balloon אישור
Aviram Seo
 
TDC2016SP - Criando modelos em nuvem com Azure Machine Learning
TDC2016SP - Criando modelos em nuvem com Azure Machine LearningTDC2016SP - Criando modelos em nuvem com Azure Machine Learning
TDC2016SP - Criando modelos em nuvem com Azure Machine Learning
tdc-globalcode
 
TDC2016SP - SparkMLlib Machine Learning na Prática
TDC2016SP -  SparkMLlib Machine Learning na PráticaTDC2016SP -  SparkMLlib Machine Learning na Prática
TDC2016SP - SparkMLlib Machine Learning na Prática
tdc-globalcode
 
TDC2016SP - Colocando modelos de Machine Learning em produção.
TDC2016SP - Colocando modelos de Machine Learning em produção.TDC2016SP - Colocando modelos de Machine Learning em produção.
TDC2016SP - Colocando modelos de Machine Learning em produção.
tdc-globalcode
 
El circuit electric_1er_eso
El circuit electric_1er_esoEl circuit electric_1er_eso
El circuit electric_1er_eso
lborrasborras
 
William Giba Digital Resume/CV
William Giba Digital Resume/CVWilliam Giba Digital Resume/CV
William Giba Digital Resume/CV
William Giba
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
Java Programming
 
Ad

Similar to C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II (20)

c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
RSathyaPriyaCSEKIOT
 
Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
Selva Arrunaa Mathavan
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
umar78600
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University
 
The New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of theThe New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of the
shubhamgupta7133
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
Ajeet Kumar
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variables
yarkhosh
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
Rai University
 
Computer Programming In C - Variables, Constants & Data Types
Computer Programming In C - Variables, Constants & Data TypesComputer Programming In C - Variables, Constants & Data Types
Computer Programming In C - Variables, Constants & Data Types
DeepaV79
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
Rai University
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Rai University
 
C language ppt is a presentation of how to explain the introduction of a c la...
C language ppt is a presentation of how to explain the introduction of a c la...C language ppt is a presentation of how to explain the introduction of a c la...
C language ppt is a presentation of how to explain the introduction of a c la...
sdsharmila11
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptxChapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
Variables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in cVariables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
Chapter02.PPT
Chapter02.PPTChapter02.PPT
Chapter02.PPT
Chaitanya Jambotkar
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C ProgrammingIntroduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
introduction2_programming slides briefly exolained
introduction2_programming slides briefly exolainedintroduction2_programming slides briefly exolained
introduction2_programming slides briefly exolained
RumaSinha8
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
umar78600
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University
 
The New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of theThe New Yorker cartoon premium membership of the
The New Yorker cartoon premium membership of the
shubhamgupta7133
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
Ajeet Kumar
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variables
yarkhosh
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
Rai University
 
Computer Programming In C - Variables, Constants & Data Types
Computer Programming In C - Variables, Constants & Data TypesComputer Programming In C - Variables, Constants & Data Types
Computer Programming In C - Variables, Constants & Data Types
DeepaV79
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS4 Introduction to C.pptxSSSSSSSSSSSSSSSS
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
Rai University
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Rai University
 
C language ppt is a presentation of how to explain the introduction of a c la...
C language ppt is a presentation of how to explain the introduction of a c la...C language ppt is a presentation of how to explain the introduction of a c la...
C language ppt is a presentation of how to explain the introduction of a c la...
sdsharmila11
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptxChapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
Variables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in cVariables, identifiers, constants, declaration in c
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C ProgrammingIntroduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
introduction2_programming slides briefly exolained
introduction2_programming slides briefly exolainedintroduction2_programming slides briefly exolained
introduction2_programming slides briefly exolained
RumaSinha8
 
Ad

More from ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE (8)

UNIT-V.pptx-big data notes-ccs334anna university syllabus
UNIT-V.pptx-big data notes-ccs334anna university  syllabusUNIT-V.pptx-big data notes-ccs334anna university  syllabus
UNIT-V.pptx-big data notes-ccs334anna university syllabus
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
BIGDATA ANALYTICS LAB MANUAL final.pdf
BIGDATA  ANALYTICS LAB MANUAL final.pdfBIGDATA  ANALYTICS LAB MANUAL final.pdf
BIGDATA ANALYTICS LAB MANUAL final.pdf
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORYGE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING-UNIT I
GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING-UNIT IGE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING-UNIT I
GE8151-PROBLEM SOLVING AND PYTHON PROGRAMMING-UNIT I
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
IT6701-Information management question bank
IT6701-Information management question bankIT6701-Information management question bank
IT6701-Information management question bank
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
STUDY EDUCATIONAL OPERATING SYSTEM MINIX OPERATING SYSTEM AND DEVELOP REASO...
STUDY  EDUCATIONAL OPERATING  SYSTEM MINIX OPERATING SYSTEM AND DEVELOP REASO...STUDY  EDUCATIONAL OPERATING  SYSTEM MINIX OPERATING SYSTEM AND DEVELOP REASO...
STUDY EDUCATIONAL OPERATING SYSTEM MINIX OPERATING SYSTEM AND DEVELOP REASO...
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
Using fuzzy ant colony optimization for Diagnosis of Diabetes Disease
Using fuzzy ant colony optimization for Diagnosis of Diabetes DiseaseUsing fuzzy ant colony optimization for Diagnosis of Diabetes Disease
Using fuzzy ant colony optimization for Diagnosis of Diabetes Disease
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 
Wireless sensor networks
Wireless sensor networksWireless sensor networks
Wireless sensor networks
ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE
 

Recently uploaded (20)

Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdfComputer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
IOt Based Research on Challenges and Future
IOt Based Research on Challenges and FutureIOt Based Research on Challenges and Future
IOt Based Research on Challenges and Future
SACHINSAHU821405
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
Structure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS pptStructure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS ppt
Wahajch
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.
Sowndarya6
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
May 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information TechnologyMay 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptxWeek 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior DevelopersDavid Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
The first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptxThe first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptx
Mayank Mathur
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
SharinAbGhani1
 
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptxSemi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
studyshubham18
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyRigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdfComputer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
IOt Based Research on Challenges and Future
IOt Based Research on Challenges and FutureIOt Based Research on Challenges and Future
IOt Based Research on Challenges and Future
SACHINSAHU821405
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
Structure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS pptStructure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS ppt
Wahajch
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.Third Review PPT that consists of the project d etails like abstract.
Third Review PPT that consists of the project d etails like abstract.
Sowndarya6
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
May 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information TechnologyMay 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptxWeek 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior DevelopersDavid Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
The first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptxThe first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptx
Mayank Mathur
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
02 - Ethics & Professionalism - BEM, IEM, MySET.PPT
SharinAbGhani1
 
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptxSemi-Conductor ppt ShubhamSeSemi-Con.pptx
Semi-Conductor ppt ShubhamSeSemi-Con.pptx
studyshubham18
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyRigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 

C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II

  • 4. CHARACTER SET C CHARACTER SET Execution Character Set Source Character Set DigitsAlphabets Special Character White Space Character Space Escape Sequence PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 5. A Character denotes an alphabet, digit or a special character. Lowercase Letters – A,B,C….. Z Uppercase Letters - a,b,c…… z Digits – 0,1,2,3,…7,8,9 + Plus Sign - Minus Sign , Comma * Asterisk / Slash = Equal to @ At Symbol < Less Than : Colon ; Semicolon PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 6. It will work at the execution time only and it cannot be printed. It always represented by a backslash() followed by a character. PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 7.  The smallest individual units of a c program are known as tokens  It can be categorized into following ways C tokens operators Special symbolstringconstantsIdentifiersKeywords PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 8.  Keyword is a reserved keyword that has a particular meaning  It should be in lower case  There are 32 keywords in c language S. NO keyword S. NO keyword S.NO keyword S. NO keyword keyword 1 auto 8 do 15 goto 22 signed 29.unsigned 2 break 9 double 16 if 23 sizeof 30.void 3 case 10 else 17 int 24 static 31.volatile 4 char 11 enum 18 long 25 struct 32.while 5 const 12 extern 19 register 26 switch 6 continue 13 float 20 return 27 typedef 7 default 14 for 21 short 28 union PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 9.  It can be a variable name and function name etc.  Maximum length of an identifier is 31  Special character are not allowed except(_). Valid invalid nithiya Nithya# NITHIYA Nith ya ->blank space Nithya3 Auto Nithya 3nithya PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 11. Variables are named locations in memory that are used to hold a value that may be modified by the program. K5.ico ANIMATAY006.ICO The syntax for declaring a variable is Data type Variablename; Valid Examples : CSC avg_val m1 Chennai Anu mark_1 PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 12. RULES for framing a variable : The first character in the Variable name must be an alphabet Alphabets can be followed by a number of digits or underscores No commas or Blank spaces are allowed within a variable name No Special character other than Underscore(_) can be used in a variable name. The variable name should not be a keyword Variable names are case sensitive It should not be of length more than 31 characters PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 13. INTIALIZING VARIABLE Assigning some value to the variable is known as intialization SYNTAX: Data type variable name=value; Example Int a=10; SCOPE OF VARIABLE 1.Local variable 2.Global variable PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 14. Scope of variable definition example Local variable Declared inside the block main() { Int a=8; // local variable } Global variable Declared before the main function Int a=8; Main() { //no of statement } PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 15. C data types Empty data type User defined data type Derived or secondary data type Primary data type PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG PRIMARY DATA TYPES int float chardouble 1.PRIMARY DATA TYPES
  • 16. S.N O Data Type Explanation Size(bytes) CONTRO L STRING RANGE SYNTAX EXAMPLE 1 int It store numeric values without decimal point Example:9,10,23 2 bytes %d or %i -32,768 to +32,767 int Variable_na me; int roll_no; 2 float It store the numeric values with decimal point Example:3.12,47.098 4 bytes %f or %g 3.4E-38 to 3.4E+38 Float Variable_na me; float a; 3 double It store the big number of decimal point Example:2.13455 8 bytes %if 1.7E-308 to 1.7E+308 Double Variable name; double b; 4 char It store the single character Example:’a’,’9’ 1 bytes %c -128 to +127 Char Variable name; char a=“nithiya”; PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 17. 1.Array An array is a collection of variable of same data type SYNTAX: Datatype array_name[array size]; Example: int a[10]; 2.Structures it stores the multiple values of same or different data type under a single name Syntax: Struct <struct name> { Member 1;member 2;}; DERIVED DATA TYPE array pointersunionsstructures
  • 18. EXAMPLE: Struct Student { Char name[10]; Int roll_no; }; 3.UNION A union is store the multiple values of same or different data type SYNTAX: union <union name> { Member 1; member 2; } EXAMPLE: Union student { Char name[25]; }; PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 19. 4.POINTERS A pointer is holds the memory address of another variable SYNTAX: Data type *variable name EXAMPLE : int *a EMPTY DATA TYPE i)Void its represents an empty value PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 20. 1.Type Definition Example: Typedef int age; age male,female 2.Enumerated Datatype Example : enum mon{jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec }; PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG USER DEFINED DATA TYPE
  • 21. Control statement conditional unconditional selective looping Nested if else Simple if If else If-else if ladder Switch case while do while for goto break continue PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 22.  A program is a sequence of one or more instructions  The condition will check whether the particular condition are true (or) not.  1.SIMPLE IF STATEMENT  If the condition is true the set of statements are executed  SYNTAX  if(condition) { Statement 1; } PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 23. To find the given no is even or odd #include<stdio.h> #include<conio.h> main() { int no; clrscr(); printf(“n Enter the number”); scanf(“%d”,&no); if(no%2==0) { printf(The given no is even”); }} Output Enter the number 24 The given no is even PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 24. 2.if else statement It is a two way decision making statement SYNTAX: if(condition) { Statement 1; } else { false statement; } #include<stdio.h> #include<conio.h> main() { int no; clrscr(); printf(“n Enter the number”); scanf(“%d”,&no); if(no%2==0) { printf(The given no is even”); } else { Printf(“The given no is odd”); } #include<stdio.h> #include<conio.h> main() { int no; clrscr(); printf(“n Enter the number”); scanf(“%d”,&no); if(no%2==0) { printf(The given no is even”); } else { Printf(“The given no is odd”); } Output Enter the number 25 The given no is odd PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 25.  The number of logical conditions is checked for executing various statements  SYNTAX  if(condition 1)  {  True statement 1;  }  else  {  if(condition 2)  {  True statement 2;  }  else  {  False statement }} #include<stdio.h> #include<conio.h> Main() { int a,b,c; clrscr(); printf(“Enter a,b,c”); scanf(“%d%d%d”,&a,&b,&c); if((a>b)&&(a>c)) { printf(“A is greater”); } else { If(b>c) { printf(“B is greater”); } else { printf(“C is greater”); }}} Output Enter the values of a,b,c 4 2 3 A is greater
  • 26. Nested if-else can be chained with one another Syntax: if(condition 1) { Statement 1; } else if(condition 2); { Statement 2; } else if(condition 3) { statement; } else { Final statement } #include<stdio.h> #include<conio.h> Main() { int a,b,c; clrscr(); printf(“Enter a,b,c”); scanf(“%d%d%d”,&a,&b,&c); if(a>b) { If(a>c) { printf(“A is greater”); } else { printf(“C is greater”); } } else if(b>c) { printf(“B is greater”); } else { printf(“C is greater”); }} Output Enter the values of a,b,c 4 2 3 A is greater PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG
  • 27.  If the value matches with case constant, this particular case statement is executed. if not default is executed.  SYNTAX:  Switch (variable)  {  Case constant 1:  statement 1;  Break;  Case constant 2:  Statement 2;  Break;  ..  ..  default:  Default statement;  } #include<stdio.h> #include<conio.h> Main() { int a=10,b=5; char symbol; clrscr(); printf(“Enter the symbol”); scanf(“%c”,&symbol); switch(symbol) { case’+’: result=a+b; break; case’-’: result=a-b; break; case’*’: Result=a*b; Break; Case’/’: Result=a/b; break; case’%’: Result=a%b; break; } Default: Printf(“invalid symbol”); } Printf(“the result is %d”,result); } Output Enter the symbol:+ The result is 15 Enter the symbol:% The result is 0 PREPARED BY K,NITHIYA AP/IT ANNAI CLG OF ENGG