SlideShare a Scribd company logo
Getting Started
What you’ll learn:
1. Basic Structure of a C
Program
2. Basic Syntax of C language
3. Data Types
4. Defining Variables and
Constants
5. Console I/O
Getting Started
Basic Structure
Basic Structure
A C program basically consists of the following parts:
 Pre-processor Commands
 Functions
 Variables
 Statements & Expressions
 Comments
Getting Started
Basic Syntax
Character Set
 Letters: A-Z a-z
 Digits: 0-9
 Symbols: + - * / % = _ |  ~ ^ / ? ! @ # $ & : ; “ ‘ ` , . < > () {} []
 ASCII symbols: 256 characters including the above ones.
 Unicode symbols: UTF-8 can represent all 1,114,112 Unicode characters.
Tokens
o Keywords
o Identifiers
o Literals
o Strings
o Punctuators
o Operators
Keywords
32 Keywords from C89
auto double int struct break else long switch
case enum register typedef char extern return union
const float short unsigned continue for signed void
default goto sizeof volatile do if static while
5 Keywords from C99
_Bool _Imaginary
restrict _Complex
inline
6 Keywords from C11
_Alignas _Atomic
_Noreturn _Alignof
_Generic _Static_assert
Identifiers
Rules for defining Identifiers
 It can only contain letters, digits, or an underscore.
 It should not start with a digit. It can start with a letter or an underscore.
 A keyword should not be used as an identifier.
 Since C is a case sensitive language so uppercase letters differ from lowercase ones.
Apple apple
Valid and Invalid Identifiers
 Valid Identifiers:-
VarName VAR2NAME _var11 var_name_11 int_100
 Invalid identifiers:-
var-name 11varname int var name $var_name
Literals
Literals are also called constants. We have following type of constants:
 Integer constant 1, -11, 0xC, 010
 Floating constant -32.56, 0.9787
 Character constant ‘a’, ‘1’, ‘#’
Strings
 String literal is a sequence of characters.
E.g. “Hello”
 It is terminated by ‘0’.
E.g. “Hello” will be represented as “Hello0” in memory.
Punctuators
 Square brackets [ ]
 Parenthesis ( )
 Curly Braces { }
 Comma ,
 Terminator ;
 Colon :
 Asterisk *
 Ellipses …
 Equal =
 Pre-processor #
Basic Operators used in C
 Arithmetic: + - * / %
 Assignment: = += -= *= /= %=
 Increment/Decrement: ++ --
 Relational: == <= >= < >
 Logical: ! && ||
 Conditional: ? :
and many more…
Getting Started
Data Types
Data Types
Fundamental
 int
 float
 double
 char
 void
Derived
 Arrays
 Structure
many more ….
For integer types
MODIFIERS SIZE RANGE
Int 4 bytes -2147483648 to 2147483647
Unsigned int 4 bytes 0 to 4294967295
Signed int 4 bytes -2147483648 to 2147483647
Short int 2 bytes -32768 to 32767
Unsigned short int 2 bytes 0 to 65535
Signed short int 2 bytes -32768 to 32767
Long int 4 bytes -2147483648 to 2147483647
Signed long int 4 bytes -2147483648 to 2147483647
Unsigned long int 4 bytes 0 to 4294967295
For floating types
MODIFIERS SIZE RANGE
Float 4 bytes -3.4e-38
to +3.4e+38
Double 8 bytes -1.7e-308
to +1.7e+308
Long double 8 bytes -1.7e-308
to +1.7e+308
For character types
MODIFIERS SIZE RANGE
Char 1 byte 0 to 255
Unsigned char 1 byte 0 to 255
Signed char 1 byte -128 to +127
Getting Started
Variables and Constants
Variables
It refers to a storage location in the memory space whose value can be manipulated.
int a = 10;
a = 20;
10
20
value at
memory
location
data type
identifier
value
of the
variable
value
changed
Constants
It refers to a storage location in the memory space whose value is fixed.
const int a = 10;
a = 20;
10
10
value at
memory
location
data type
identifier
value
of the
variable
value
can’t be
changed
keyword
Getting Started
Console I/O
Console Input Output
 printf()
 scanf()
printf()
 Used to display formatted output on the console.
 Syntax:
printf(“Answer = %d”, i );
Format Specifier
Integer VariableFormatted Text
scanf()
 Used to take input from the console.
 Syntax:
scanf(“%d”, &i );
Format Specifier
Integer VariableAddress of Operator

More Related Content

What's hot

Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variablesTony Apreku
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
guest58c84c
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari
 
Constants variables data_types
Constants variables data_typesConstants variables data_types
Constants variables data_types
NAVEEN SHARMA'S CLASSROOM
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
Programming fundamental
Programming fundamentalProgramming fundamental
Programming fundamentalMukesh Thakur
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
Chitrank Dixit
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
raksharao
 
A Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsA Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Hassan293
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
eShikshak
 
Data types
Data typesData types
Data types
Nokesh Prabhakar
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
teach4uin
 
Data types in c language
Data types in c languageData types in c language
Data types in c language
HarihamShiwani
 

What's hot (19)

Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Constants variables data_types
Constants variables data_typesConstants variables data_types
Constants variables data_types
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
Programming fundamental
Programming fundamentalProgramming fundamental
Programming fundamental
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
Data type
Data typeData type
Data type
 
A Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsA Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and Expressions
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Data types
Data typesData types
Data types
 
Data type
Data typeData type
Data type
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
 
2 1 data
2 1  data2 1  data
2 1 data
 
Data types in c language
Data types in c languageData types in c language
Data types in c language
 

Viewers also liked

8.derived data types
8.derived data types8.derived data types
8.derived data typesHardik gupta
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)Hardik gupta
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
FellowBuddy.com
 

Viewers also liked (8)

5.functions
5.functions5.functions
5.functions
 
2.decision making
2.decision making2.decision making
2.decision making
 
8.derived data types
8.derived data types8.derived data types
8.derived data types
 
6.operators
6.operators6.operators
6.operators
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)
 
7.pointers
7.pointers7.pointers
7.pointers
 
4.arrays
4.arrays4.arrays
4.arrays
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
 

Similar to 1.getting started with c

Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
nikshaikh786
 
C Tutorial
C TutorialC Tutorial
C Tutorial
Dr.Subha Krishna
 
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 Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)jahanullah
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
NavyaParashir
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
Nithya K
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
Mohit Saini
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_languageSINGH PROJECTS
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
Hossein Zahed
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
joachimbenedicttulau
 
Introduction
IntroductionIntroduction
Introduction
Komal Pardeshi
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
Asirbachan Sutar
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
FatimaZafar68
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Aniket Patne
 
A798057369_21039_13_2018_Structure & Organization-Anima
A798057369_21039_13_2018_Structure & Organization-AnimaA798057369_21039_13_2018_Structure & Organization-Anima
A798057369_21039_13_2018_Structure & Organization-Anima
AbdulWahab672
 
Chapter 13.1.1
Chapter 13.1.1Chapter 13.1.1
Chapter 13.1.1patcha535
 

Similar to 1.getting started with c (20)

Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
C Tutorial
C TutorialC Tutorial
C Tutorial
 
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
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
C# overview part 1
C# overview part 1C# overview part 1
C# overview part 1
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
 
Introduction
IntroductionIntroduction
Introduction
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
Session02 c intro
Session02 c introSession02 c intro
Session02 c intro
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
A798057369_21039_13_2018_Structure & Organization-Anima
A798057369_21039_13_2018_Structure & Organization-AnimaA798057369_21039_13_2018_Structure & Organization-Anima
A798057369_21039_13_2018_Structure & Organization-Anima
 
Chapter 13.1.1
Chapter 13.1.1Chapter 13.1.1
Chapter 13.1.1
 

1.getting started with c

  • 1. Getting Started What you’ll learn: 1. Basic Structure of a C Program 2. Basic Syntax of C language 3. Data Types 4. Defining Variables and Constants 5. Console I/O
  • 3. Basic Structure A C program basically consists of the following parts:  Pre-processor Commands  Functions  Variables  Statements & Expressions  Comments
  • 5. Character Set  Letters: A-Z a-z  Digits: 0-9  Symbols: + - * / % = _ | ~ ^ / ? ! @ # $ & : ; “ ‘ ` , . < > () {} []  ASCII symbols: 256 characters including the above ones.  Unicode symbols: UTF-8 can represent all 1,114,112 Unicode characters.
  • 6. Tokens o Keywords o Identifiers o Literals o Strings o Punctuators o Operators
  • 7. Keywords 32 Keywords from C89 auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while 5 Keywords from C99 _Bool _Imaginary restrict _Complex inline 6 Keywords from C11 _Alignas _Atomic _Noreturn _Alignof _Generic _Static_assert
  • 8. Identifiers Rules for defining Identifiers  It can only contain letters, digits, or an underscore.  It should not start with a digit. It can start with a letter or an underscore.  A keyword should not be used as an identifier.  Since C is a case sensitive language so uppercase letters differ from lowercase ones. Apple apple
  • 9. Valid and Invalid Identifiers  Valid Identifiers:- VarName VAR2NAME _var11 var_name_11 int_100  Invalid identifiers:- var-name 11varname int var name $var_name
  • 10. Literals Literals are also called constants. We have following type of constants:  Integer constant 1, -11, 0xC, 010  Floating constant -32.56, 0.9787  Character constant ‘a’, ‘1’, ‘#’
  • 11. Strings  String literal is a sequence of characters. E.g. “Hello”  It is terminated by ‘0’. E.g. “Hello” will be represented as “Hello0” in memory.
  • 12. Punctuators  Square brackets [ ]  Parenthesis ( )  Curly Braces { }  Comma ,  Terminator ;  Colon :  Asterisk *  Ellipses …  Equal =  Pre-processor #
  • 13. Basic Operators used in C  Arithmetic: + - * / %  Assignment: = += -= *= /= %=  Increment/Decrement: ++ --  Relational: == <= >= < >  Logical: ! && ||  Conditional: ? : and many more…
  • 15. Data Types Fundamental  int  float  double  char  void Derived  Arrays  Structure many more ….
  • 16. For integer types MODIFIERS SIZE RANGE Int 4 bytes -2147483648 to 2147483647 Unsigned int 4 bytes 0 to 4294967295 Signed int 4 bytes -2147483648 to 2147483647 Short int 2 bytes -32768 to 32767 Unsigned short int 2 bytes 0 to 65535 Signed short int 2 bytes -32768 to 32767 Long int 4 bytes -2147483648 to 2147483647 Signed long int 4 bytes -2147483648 to 2147483647 Unsigned long int 4 bytes 0 to 4294967295
  • 17. For floating types MODIFIERS SIZE RANGE Float 4 bytes -3.4e-38 to +3.4e+38 Double 8 bytes -1.7e-308 to +1.7e+308 Long double 8 bytes -1.7e-308 to +1.7e+308
  • 18. For character types MODIFIERS SIZE RANGE Char 1 byte 0 to 255 Unsigned char 1 byte 0 to 255 Signed char 1 byte -128 to +127
  • 20. Variables It refers to a storage location in the memory space whose value can be manipulated. int a = 10; a = 20; 10 20 value at memory location data type identifier value of the variable value changed
  • 21. Constants It refers to a storage location in the memory space whose value is fixed. const int a = 10; a = 20; 10 10 value at memory location data type identifier value of the variable value can’t be changed keyword
  • 23. Console Input Output  printf()  scanf()
  • 24. printf()  Used to display formatted output on the console.  Syntax: printf(“Answer = %d”, i ); Format Specifier Integer VariableFormatted Text
  • 25. scanf()  Used to take input from the console.  Syntax: scanf(“%d”, &i ); Format Specifier Integer VariableAddress of Operator