SlideShare a Scribd company logo
PROGRAMMING IN C
Dr.K.Nithya
Assistant Professor,
Department of CSE,
SRMIST- Trichy
Life Cycle of C Program
IDE
Pre-processor
Compiler
Assembler
Loader
Linker
Program image
in memory
Source Code
add.c
Pre-processed
Code add.l
Assembly
Code add.s
Object Code
add.o
Executable Code
add.exe
Libraries &
Object files
Structure of C Program
Keywords
• In the C programming language, there are 32 keywords. All the 32 keywords have their meaning
which is already known to the compiler.
• Keywords are the reserved words with predefined meaning which already known to the compiler.
Keywords
Keywords
Identifiers
An identifier is a collection of characters which acts as the name of
variable, function, array, pointer, structure, etc.
Example
int marks;
char studentName[30];
Variable
Variable is a name given to a memory location where we can store different
values of the same datatype during the program execution.
Variable ( int number; )
A variable name may contain letters, digits and underscore symbol.
1.Variable name should not start with a digit.
2.Keywords should not be used as variable names.
3.A variable name should not contain any special symbols except underscore(_).
4.A variable name can be of any length but compiler considers only the first 31 characters
of the variable name.
Variable ( int number; )
The value of a variable can be changed, hence the name variable.
char ch = 'a';
// some code
ch = 'l’;
C is a strongly typed language. This means that the variable type cannot be
changed once it is declared.
int number = 5; // integer variable
number = 5.5; // error
double number; // error
Literals
Literals are data used for representing fixed values. They can be used
directly in the code.
For example: 1, 2.5, ‘c’ , ‘’ Good ‘’ , etc.``
• Integer Literals
• Floating-point Literals
• Character Literals
• String Literals
(i) Integer literal
It is a numeric literal that represents only integer type values. It represents the value neither in fractional nor
exponential part.
It can be specified in the following three ways:
● Decimal number (base 10)
It is defined by representing the digits between 0 to 9. For example, 45, 67, etc.
● Octal number (base 8)
It is defined as a number in which 0 is followed by digits such as 0,1,2,3,4,5,6,7. For example, 012, 034, 055, etc.
● Hexadecimal number (base 16)
It is defined as a number in which 0x or 0X is followed by the hexadecimal digits (i.e., digits from 0 to 9, alphabetical
characters from (a-z) or (A-Z)).
(ii) Floating point Literal
- Contains only floating-point values or real numbers.
- These real numbers contain the number of parts such as integer part, real part,
exponential part, and fractional part.
- The floating-point literal must be specified either in decimal or in exponential
form.
- Ex: 1.2, +9.0, -4.5 - Decimal Form
+1e23, -9e2, +2e-25 - Exponential Form
(iii) Character Literal
- Contains a single character enclosed within single quotes.
- If multiple characters are assigned to the variable, then, need to create a
character array.
- If we try to store more than one character in a variable, then the warning of a
multi-character character constant will be generated.
(iv) String Literal
- A string literal represents multiple characters enclosed within double-
quotes.
- It contains an additional character, i.e., '0' (null character), which
gets automatically inserted. This null character specifies the
termination of the string.
#include <stdio.h>
int main()
{
const int a=23; // constant integer
literal
printf("Integer literal : %d", a);
return 0;
}
Integer Literal
#include <stdio.h>
int main()
{
const float a=4.5; // constant float literal
const float b=5.6; // constant float literal
float sum;
sum=a+b;
printf("%f", sum);
return 0;
}
float literal
#include <stdio.h>
int main()
{
const char c='ak';
printf("%c",c);
return 0;
}
Character Literal
#include <stdio.h>
int main()
{
const char str[ ]= "Welcome n To n KEC";
printf("%s", str);
return 0;
}
String Literal
Escape Sequences
a Alarm or Beep
b Backspace
f Form Feed
n New Line
r Carriage Return
t Tab (Horizontal)
v Vertical Tab
 Backslash
' Single Quote
" Double Quote
? Question Mark
nnn octal number
xhh hexadecimal number
0 Null
#include<stdio.h>
int main()
{
int number=50;
printf("Younarenlearningn'c' languagen"Do you know C language"");
return 0;
}
Example program for escape sequences

More Related Content

PPTX
Basic of Structered Programming in C psd
PPT
C presentation book
PPTX
LESSON1-C_programming (1).GRADE 8 LESSONpptx
DOCX
C programming tutorial
PPTX
Introduction to C language programming.pptx
PPTX
Diploma ii cfpc u-2 datatypes and variables in c language
PPTX
C Programming Lecture 3 - Elements of C.pptx
PPTX
Bsc cs i pic u-2 datatypes and variables in c language
Basic of Structered Programming in C psd
C presentation book
LESSON1-C_programming (1).GRADE 8 LESSONpptx
C programming tutorial
Introduction to C language programming.pptx
Diploma ii cfpc u-2 datatypes and variables in c language
C Programming Lecture 3 - Elements of C.pptx
Bsc cs i pic u-2 datatypes and variables in c language

Similar to PROGRAMMING IN C - Inroduction.pptx (20)

PPT
All C ppt.ppt
PDF
Constants Variables Datatypes by Mrs. Sowmya Jyothi
PPT
CONSTANTS, VARIABLES & DATATYPES IN C
PPT
constants, variables and datatypes in C
PPTX
Mca i pic u-2 datatypes and variables in c language
PDF
C Programming Assignment
PDF
C Tutorial
PPTX
datatypes and variables in c language
PPTX
Btech i pic u-2 datatypes and variables in c language
PPTX
Module 1:Introduction
ODP
CProgrammingTutorial
PPTX
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
PPTX
FUNDAMENTAL OF C
PDF
1) VariableIn programming, a variable is a container (storage area).pdf
PPT
C language ppt is a presentation of how to explain the introduction of a c la...
PPT
THE BASIC CONCEPTS OF C PROGRAMMINGPPT.PPT
PPT
Chapter02.PPTArray.pptxArray.pptxArray.pptx
PPT
Variables, identifiers, constants, declaration in c
PPTX
C programming Training in Ambala ! Batra Computer Centre
DOCX
fds unit1.docx
All C ppt.ppt
Constants Variables Datatypes by Mrs. Sowmya Jyothi
CONSTANTS, VARIABLES & DATATYPES IN C
constants, variables and datatypes in C
Mca i pic u-2 datatypes and variables in c language
C Programming Assignment
C Tutorial
datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Module 1:Introduction
CProgrammingTutorial
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
FUNDAMENTAL OF C
1) VariableIn programming, a variable is a container (storage area).pdf
C language ppt is a presentation of how to explain the introduction of a c la...
THE BASIC CONCEPTS OF C PROGRAMMINGPPT.PPT
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Variables, identifiers, constants, declaration in c
C programming Training in Ambala ! Batra Computer Centre
fds unit1.docx
Ad

Recently uploaded (20)

PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Classroom Observation Tools for Teachers
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Trump Administration's workforce development strategy
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Classroom Observation Tools for Teachers
Anesthesia in Laparoscopic Surgery in India
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
VCE English Exam - Section C Student Revision Booklet
2.FourierTransform-ShortQuestionswithAnswers.pdf
Trump Administration's workforce development strategy
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Chinmaya Tiranga quiz Grand Finale.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
human mycosis Human fungal infections are called human mycosis..pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study
A systematic review of self-coping strategies used by university students to ...
Weekly quiz Compilation Jan -July 25.pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Ad

PROGRAMMING IN C - Inroduction.pptx

  • 1. PROGRAMMING IN C Dr.K.Nithya Assistant Professor, Department of CSE, SRMIST- Trichy
  • 2. Life Cycle of C Program IDE Pre-processor Compiler Assembler Loader Linker Program image in memory Source Code add.c Pre-processed Code add.l Assembly Code add.s Object Code add.o Executable Code add.exe Libraries & Object files
  • 3. Structure of C Program
  • 4. Keywords • In the C programming language, there are 32 keywords. All the 32 keywords have their meaning which is already known to the compiler. • Keywords are the reserved words with predefined meaning which already known to the compiler.
  • 7. Identifiers An identifier is a collection of characters which acts as the name of variable, function, array, pointer, structure, etc. Example int marks; char studentName[30]; Variable Variable is a name given to a memory location where we can store different values of the same datatype during the program execution.
  • 8. Variable ( int number; ) A variable name may contain letters, digits and underscore symbol. 1.Variable name should not start with a digit. 2.Keywords should not be used as variable names. 3.A variable name should not contain any special symbols except underscore(_). 4.A variable name can be of any length but compiler considers only the first 31 characters of the variable name.
  • 9. Variable ( int number; ) The value of a variable can be changed, hence the name variable. char ch = 'a'; // some code ch = 'l’; C is a strongly typed language. This means that the variable type cannot be changed once it is declared. int number = 5; // integer variable number = 5.5; // error double number; // error
  • 10. Literals Literals are data used for representing fixed values. They can be used directly in the code. For example: 1, 2.5, ‘c’ , ‘’ Good ‘’ , etc.`` • Integer Literals • Floating-point Literals • Character Literals • String Literals
  • 11. (i) Integer literal It is a numeric literal that represents only integer type values. It represents the value neither in fractional nor exponential part. It can be specified in the following three ways: ● Decimal number (base 10) It is defined by representing the digits between 0 to 9. For example, 45, 67, etc. ● Octal number (base 8) It is defined as a number in which 0 is followed by digits such as 0,1,2,3,4,5,6,7. For example, 012, 034, 055, etc. ● Hexadecimal number (base 16) It is defined as a number in which 0x or 0X is followed by the hexadecimal digits (i.e., digits from 0 to 9, alphabetical characters from (a-z) or (A-Z)).
  • 12. (ii) Floating point Literal - Contains only floating-point values or real numbers. - These real numbers contain the number of parts such as integer part, real part, exponential part, and fractional part. - The floating-point literal must be specified either in decimal or in exponential form. - Ex: 1.2, +9.0, -4.5 - Decimal Form +1e23, -9e2, +2e-25 - Exponential Form
  • 13. (iii) Character Literal - Contains a single character enclosed within single quotes. - If multiple characters are assigned to the variable, then, need to create a character array. - If we try to store more than one character in a variable, then the warning of a multi-character character constant will be generated.
  • 14. (iv) String Literal - A string literal represents multiple characters enclosed within double- quotes. - It contains an additional character, i.e., '0' (null character), which gets automatically inserted. This null character specifies the termination of the string.
  • 15. #include <stdio.h> int main() { const int a=23; // constant integer literal printf("Integer literal : %d", a); return 0; } Integer Literal #include <stdio.h> int main() { const float a=4.5; // constant float literal const float b=5.6; // constant float literal float sum; sum=a+b; printf("%f", sum); return 0; } float literal
  • 16. #include <stdio.h> int main() { const char c='ak'; printf("%c",c); return 0; } Character Literal #include <stdio.h> int main() { const char str[ ]= "Welcome n To n KEC"; printf("%s", str); return 0; } String Literal
  • 17. Escape Sequences a Alarm or Beep b Backspace f Form Feed n New Line r Carriage Return t Tab (Horizontal) v Vertical Tab Backslash ' Single Quote " Double Quote ? Question Mark nnn octal number xhh hexadecimal number 0 Null
  • 18. #include<stdio.h> int main() { int number=50; printf("Younarenlearningn'c' languagen"Do you know C language""); return 0; } Example program for escape sequences