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 (19)

PPTX
Lecture 2 variables
Tony Apreku
 
PPT
C Sharp Nagina (1)
guest58c84c
 
PPT
constants, variables and datatypes in C
Sahithi Naraparaju
 
PPTX
Constant, variables, data types
Pratik Devmurari
 
PPTX
Constants variables data_types
NAVEEN SHARMA'S CLASSROOM
 
PPTX
What is identifier c programming
Rumman Ansari
 
PPTX
Programming fundamental
Mukesh Thakur
 
PPTX
Constants and variables in c programming
Chitrank Dixit
 
PPT
Data types and Operators
raksharao
 
PPSX
Data type
Frijo Francis
 
PPTX
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
PPTX
Programming Fundamentals
Hassan293
 
PPT
Mesics lecture 3 c – constants and variables
eShikshak
 
PPTX
Data types
Nokesh Prabhakar
 
DOC
Data type
Isha Aggarwal
 
PPTX
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 
PPT
3 data-types-in-c
teach4uin
 
PPT
2 1 data
Ken Kretsch
 
PPTX
Data types in c language
HarihamShiwani
 
Lecture 2 variables
Tony Apreku
 
C Sharp Nagina (1)
guest58c84c
 
constants, variables and datatypes in C
Sahithi Naraparaju
 
Constant, variables, data types
Pratik Devmurari
 
Constants variables data_types
NAVEEN SHARMA'S CLASSROOM
 
What is identifier c programming
Rumman Ansari
 
Programming fundamental
Mukesh Thakur
 
Constants and variables in c programming
Chitrank Dixit
 
Data types and Operators
raksharao
 
Data type
Frijo Francis
 
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
Programming Fundamentals
Hassan293
 
Mesics lecture 3 c – constants and variables
eShikshak
 
Data types
Nokesh Prabhakar
 
Data type
Isha Aggarwal
 
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 
3 data-types-in-c
teach4uin
 
2 1 data
Ken Kretsch
 
Data types in c language
HarihamShiwani
 

Viewers also liked (8)

PPTX
5.functions
Hardik gupta
 
PPTX
2.decision making
Hardik gupta
 
PPTX
8.derived data types
Hardik gupta
 
PPTX
6.operators
Hardik gupta
 
PPTX
3.looping(iteration statements)
Hardik gupta
 
PPTX
7.pointers
Hardik gupta
 
PPTX
4.arrays
Hardik gupta
 
PDF
Programming & Data Structure Lecture Notes
FellowBuddy.com
 
5.functions
Hardik gupta
 
2.decision making
Hardik gupta
 
8.derived data types
Hardik gupta
 
6.operators
Hardik gupta
 
3.looping(iteration statements)
Hardik gupta
 
7.pointers
Hardik gupta
 
4.arrays
Hardik gupta
 
Programming & Data Structure Lecture Notes
FellowBuddy.com
 
Ad

Similar to 1.getting started with c (20)

PPTX
LESSON1-C_programming (1).GRADE 8 LESSONpptx
joachimbenedicttulau
 
PPT
Introduction to C Programming
MOHAMAD NOH AHMAD
 
PPT
Unit 4 Foc
JAYA
 
PPTX
Structure of c_program_to_input_output
Anil Dutt
 
PPT
Introduction to C
Janani Satheshkumar
 
PPT
Unit i intro-operators
HINAPARVEENAlXC
 
PPTX
Introduction to C language programming.pptx
OVIDMAMAH
 
PPTX
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
PPTX
c_pro_introduction.pptx
RohitRaj744272
 
PPT
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju
 
PDF
C programming language
Mahmoud Eladawi
 
PPT
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
PPTX
Module 1:Introduction
nikshaikh786
 
PPT
C the basic concepts
Abhinav Vatsa
 
ODP
CProgrammingTutorial
Muthuselvam RS
 
PPTX
Aniket tore
anikettore1
 
PPTX
C introduction
AswathyBAnil
 
DOCX
Theory1&amp;2
Dr.M.Karthika parthasarathy
 
PPTX
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
PPT
C presentation book
krunal1210
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
joachimbenedicttulau
 
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Unit 4 Foc
JAYA
 
Structure of c_program_to_input_output
Anil Dutt
 
Introduction to C
Janani Satheshkumar
 
Unit i intro-operators
HINAPARVEENAlXC
 
Introduction to C language programming.pptx
OVIDMAMAH
 
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
c_pro_introduction.pptx
RohitRaj744272
 
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju
 
C programming language
Mahmoud Eladawi
 
Fundamental of C Programming Language and Basic Input/Output Function
imtiazalijoono
 
Module 1:Introduction
nikshaikh786
 
C the basic concepts
Abhinav Vatsa
 
CProgrammingTutorial
Muthuselvam RS
 
Aniket tore
anikettore1
 
C introduction
AswathyBAnil
 
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
C presentation book
krunal1210
 
Ad

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