SlideShare a Scribd company logo
1 of 27
Download to read offline
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

C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and UnionsDhrumil Patel
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingRokonuzzaman Rony
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and DestructorKamal Acharya
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C ProgrammingQazi Shahzad Ali
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++Fahim Adil
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I vampugani
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 

What's hot (20)

C Structures And Unions
C  Structures And  UnionsC  Structures And  Unions
C Structures And Unions
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Structure in c
Structure in cStructure in c
Structure in c
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Functions in C
Functions in CFunctions in C
Functions in C
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
 
Type conversion
Type  conversionType  conversion
Type conversion
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Function in c
Function in cFunction in c
Function in c
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 

Similar to Unit ii ppt

T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogramprincepavan
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogramprincepavan
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptxganeshkarthy
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++K Durga Prasad
 
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 languageRai University
 
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 languageRai University
 
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 languageRai 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 languageRai University
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing TutorialMahira Banu
 
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.pptxKrishanPalSingh39
 

Similar to Unit ii ppt (20)

T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Unit 3 arrays and_string
Unit 3 arrays and_stringUnit 3 arrays and_string
Unit 3 arrays and_string
 
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
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
 
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
 
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
 
Ppt of c vs c#
Ppt of c vs c#Ppt of c vs c#
Ppt of c vs c#
 
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
 
1 Revision Tour
1 Revision Tour1 Revision Tour
1 Revision Tour
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
C language
C languageC language
C language
 
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
 

More from ANJALAI AMMAL MAHALINGAM ENGINEERING COLLEGE (8)

BIGDATA ANALYTICS LAB MANUAL final.pdf
BIGDATA  ANALYTICS LAB MANUAL final.pdfBIGDATA  ANALYTICS LAB MANUAL final.pdf
BIGDATA ANALYTICS LAB MANUAL final.pdf
 
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
 
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
 
IT6701-Information management question bank
IT6701-Information management question bankIT6701-Information management question bank
IT6701-Information management question bank
 
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT IIC PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
 
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...
 
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
 
Wireless sensor networks
Wireless sensor networksWireless sensor networks
Wireless sensor networks
 

Recently uploaded

AntColonyOptimizationManetNetworkAODV.pptx
AntColonyOptimizationManetNetworkAODV.pptxAntColonyOptimizationManetNetworkAODV.pptx
AntColonyOptimizationManetNetworkAODV.pptxLina Kadam
 
Indian Tradition, Culture & Societies.pdf
Indian Tradition, Culture & Societies.pdfIndian Tradition, Culture & Societies.pdf
Indian Tradition, Culture & Societies.pdfalokitpathak01
 
Ergodomus - LOD 400 Production Drawings Exampes - Copy.pdf
Ergodomus - LOD 400 Production Drawings Exampes - Copy.pdfErgodomus - LOD 400 Production Drawings Exampes - Copy.pdf
Ergodomus - LOD 400 Production Drawings Exampes - Copy.pdfgestioneergodomus
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptxTriangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptxRomil Mishra
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organizationchnrketan
 
Introduction to Machine Learning Part1.pptx
Introduction to Machine Learning Part1.pptxIntroduction to Machine Learning Part1.pptx
Introduction to Machine Learning Part1.pptxPavan Mohan Neelamraju
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesSreedhar Chowdam
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labsamber724300
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...shreenathji26
 
Structural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot MuiliStructural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot MuiliNimot Muili
 
Livre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdf
Livre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdfLivre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdf
Livre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdfsaad175691
 
ADM100 Running Book for sap basis domain study
ADM100 Running Book for sap basis domain studyADM100 Running Book for sap basis domain study
ADM100 Running Book for sap basis domain studydhruvamdhruvil123
 
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...gerogepatton
 
Introduction of Object Oriented Programming Language using Java. .pptx
Introduction of Object Oriented Programming Language using Java. .pptxIntroduction of Object Oriented Programming Language using Java. .pptx
Introduction of Object Oriented Programming Language using Java. .pptxPoonam60376
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 
Chapter 9 Mechanical Injection Systems.pdf
Chapter 9 Mechanical Injection Systems.pdfChapter 9 Mechanical Injection Systems.pdf
Chapter 9 Mechanical Injection Systems.pdfFaizanAhmed396943
 
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...Amil baba
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 

Recently uploaded (20)

AntColonyOptimizationManetNetworkAODV.pptx
AntColonyOptimizationManetNetworkAODV.pptxAntColonyOptimizationManetNetworkAODV.pptx
AntColonyOptimizationManetNetworkAODV.pptx
 
Indian Tradition, Culture & Societies.pdf
Indian Tradition, Culture & Societies.pdfIndian Tradition, Culture & Societies.pdf
Indian Tradition, Culture & Societies.pdf
 
Ergodomus - LOD 400 Production Drawings Exampes - Copy.pdf
Ergodomus - LOD 400 Production Drawings Exampes - Copy.pdfErgodomus - LOD 400 Production Drawings Exampes - Copy.pdf
Ergodomus - LOD 400 Production Drawings Exampes - Copy.pdf
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptxTriangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptx
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organization
 
Introduction to Machine Learning Part1.pptx
Introduction to Machine Learning Part1.pptxIntroduction to Machine Learning Part1.pptx
Introduction to Machine Learning Part1.pptx
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labs
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
 
Structural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot MuiliStructural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
Structural Integrity Assessment Standards in Nigeria by Engr Nimot Muili
 
Livre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdf
Livre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdfLivre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdf
Livre Implementing_Six_Sigma_and_Lean_A_prac([Ron_Basu]_).pdf
 
ADM100 Running Book for sap basis domain study
ADM100 Running Book for sap basis domain studyADM100 Running Book for sap basis domain study
ADM100 Running Book for sap basis domain study
 
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
 
Introduction of Object Oriented Programming Language using Java. .pptx
Introduction of Object Oriented Programming Language using Java. .pptxIntroduction of Object Oriented Programming Language using Java. .pptx
Introduction of Object Oriented Programming Language using Java. .pptx
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 
Chapter 9 Mechanical Injection Systems.pdf
Chapter 9 Mechanical Injection Systems.pdfChapter 9 Mechanical Injection Systems.pdf
Chapter 9 Mechanical Injection Systems.pdf
 
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 

Unit ii ppt

  • 1.
  • 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