SlideShare uma empresa Scribd logo
1 de 18
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

Mais conteúdo relacionado

Semelhante a PROGRAMMING IN C - Inroduction.pptx

434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
MAHESHV559910
 

Semelhante a PROGRAMMING IN C - Inroduction.pptx (20)

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++
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
Session02 c intro
Session02 c introSession02 c intro
Session02 c intro
 
C# overview part 1
C# overview part 1C# overview part 1
C# overview part 1
 
Introduction
IntroductionIntroduction
Introduction
 
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
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
 
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
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C programming language
C programming languageC programming language
C programming language
 
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
 
C language
C languageC language
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
 
CSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdfCSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdf
 

Último

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
17thcssbs2
 

Último (20)

The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon season
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptx
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 

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