SlideShare a Scribd company logo
BY REHAN IJAZ
04- Getting Started with C
BY REHAN IJAZ
C's Character Set
C does not use, nor requires the use of, every character found on a modern computer
keyboard. The use of most of this set of characters will be discussed throughout the course. The
only characters required by the C Programming Language are as follows:
character:- It denotes any alphabet, digit or special symbol used to represent information.
Use:- These characters can be combined to form variables. C uses variables, operators,
keywords and expressions as building blocks to form a basic C program.
Character set:- The character set is the fundamental raw material of any language and they are
used to represent information. Like natural languages, computer language will also have well
defined character set, which is useful to build the programs.
The characters in C are grouped into the following two categories:
1. Source characterset
a. Alphabets
b. Digits
c. Special Characters
d. White Spaces
2. Execution characterset
a. Escape Sequence
1. Source character set
ALPHABETS
Uppercase letters A-Z
Lowercase letters a-z
DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
SPECIAL CHARACTERS
WHITESPACE CHARACTERS
b blank space t horizontal tab v vertical tab r carriage return f form feed n new line
BY REHAN IJAZ
 Back slash ’ Single quote " Double quote ? Question mark 0 Null a Alarm (bell)
2. Execution Character Set
Certain ASCII characters are unprintable, which means they are not displayed on the screen or
printer. Those characters perform other functions aside from displaying text. Examples are
backspacing or moving to a newline .
They are used in output statements. Escape sequence usually consists of a backslash and a
letter or a combination of digits. An escape sequence is considered as a single character but a
valid character constant.
These are employed at the time of execution of the program. Execution characters set are
always represented by a backslash () followed by a character. Note that each one of character
constants represents one character, although they consist of two characters. These characters
combinations are called as escape sequence.
Escape Sequence
Invalid Sequence
#include <stdio.h>
int main()
{
printf("Hello,
world!");
}
Correct Sequence
#include <stdio.h>
int main()
{
printf("Hello,nworld!");
}
BY REHAN IJAZ
More Escape Sequences
 Null 0 Null
 Alarm (bell) a Beep Sound
 Back space b Moves previous position
 Horizontal tab t Moves next horizontal tab
 New line n Moves next Line
 Vertical tab v Moves next vertical tab
 Form feed f Moves initial position of next page
 Carriage return r Moves beginning of the line
 Double quote " Present Double quotes
 Single quote ' Present Apostrophe
 Question mark ? Present Question Mark
 Back slash  Present back slash
BY REHAN IJAZ
C’s Variable
 C variable is a named location in a memory where a program can manipulate the data.
This location is used to hold the value of the variable.
 The value of the C variable may get change in the program.
 C variable might be belonging to any of the data type like int, float, char etc.
Rules for naming C variable:
1. Variable name must begin with letter or underscore.
2. Variable names are case sensitive
3. They can be constructed with digits, letters.
4. No special symbols are allowed other than underscore.
5. sum, height, _value are some examples for variable name
Declaring & initializing C variable:
 Variables should be declared in the C program before to use.
 Memory space is not allocated for a variable while declaration. It happens only on
variable definition.
 Variable initialization means assigning a value to the variable.
S.No Type Syntax Example
1 Variable
declaration
data_type variable_name; int x, y, z; char flat, ch;
2 Variable
initialization
data_type variable_name =
value;
int x = 50, y = 30; char flag
= ‘x’, ch=’l’;
Variable types
There are three types of variables in C program They are,
1. Local variable
2. Global variable
3. Environment variable
BY REHAN IJAZ
1. Example program for local variable in C:
 The scope of local variables will be within the function only.
 These variables are declared within the function and can’t be accessed outside the
function.
 In the below example, m and n variables are having scope within the main function only.
These are not visible to test function.
 Like wise, a and b variables are having scope within the test function only. These are not
visible to main function.
#include<stdio.h>
void test();
int main()
{
int m = 22, n = 44;
printf(“nvalues : m = %d and n = %d”, m, n);
test();
}
void test()
{
int a = 50, b = 80;
printf(“nvalues : a = %d and b = %d”, a, b);
}
Output:
values : m = 22 and n = 44
values : a = 50 and b = 80
BY REHAN IJAZ
2. Example program for global variable in C:
 The scope of global variables will be throughout the program. These variables can be
accessed from anywhere in the program.
 This variable is defined outside the main function. So that, this variable is visible to main
function and all other sub functions.
#include<stdio.h>
void test();int m = 22, n = 44;
int a = 50, b = 80;
int main()
{
printf(“All variables are accessed from main function”);
printf(“nvalues: m=%d:n=%d:a=%d:b=%d”, m,n,a,b);
test();
}
void test()
{
printf(“nnAll variables are accessed from”
” test function”);
printf(“nvalues: m=%d:n=%d:a=%d:b=%d”, m,n,a,b);
}
Output:
All variables are accessed from main function
values : m = 22 : n = 44 : a = 50 : b = 80
All variables are accessed from test function
values : m = 22 : n = 44 : a = 50 : b = 80
BY REHAN IJAZ
C’s Identifiers
Identifiers in C language:
 Each program elements in a C program are given a name called identifiers.
 Names given to identify Variables, functions and arrays are examples for identifiers. eg.
x is a name given to integer variable in above program.
Rules for constructing identifier name in C:
1. First character should be an alphabet or underscore.
2. Succeeding characters might be digits or letter.
3. Punctuation and special characters aren’t allowed except underscore.
4. Identifiers should not be keywords.
BY REHAN IJAZ
C’s Key words
 Keywords are pre-defined words in a C compiler.
 Each keyword is meant to perform a specific function in a C program.
 Since keywords are referred names for compiler, they can’t be used as variable name.
C language supports 32 keywords which are given below.
auto double int struct const float short unsigned
break else long switch continue for signed void
case enum register typedef default goto sizeof volatile
char extern return union do if static while
BY REHAN IJAZ

More Related Content

PPSX
Complete C programming Language Course
PPTX
Programming C Language
PPTX
Sample for Simple C Program - R.D.Sivakumar
PPTX
What is c
PPTX
C language basics
PPTX
Basic Input and Output
PPTX
Introduction to Basic C programming 02
Complete C programming Language Course
Programming C Language
Sample for Simple C Program - R.D.Sivakumar
What is c
C language basics
Basic Input and Output
Introduction to Basic C programming 02

What's hot (20)

PPTX
Data Input and Output
PPTX
C Token’s
PPSX
Concepts of C [Module 2]
PPTX
Operators and expressions in c language
PPT
C program compiler presentation
PDF
Unit ii chapter 2 Decision making and Branching in C
PDF
C programming Workshop
PPT
Variables in C Programming
PPTX
Introduction to C programming
PPTX
Input output statement in C
PPT
CPU INPUT OUTPUT
PDF
Learn C# Programming - Operators
PPT
Input And Output
PPTX
C Language (All Concept)
PDF
C Programming
PPTX
datatypes and variables in c language
PPT
pointer, structure ,union and intro to file handling
PPT
Mesics lecture 5 input – output in ‘c’
PPTX
C programming(Part 1)
Data Input and Output
C Token’s
Concepts of C [Module 2]
Operators and expressions in c language
C program compiler presentation
Unit ii chapter 2 Decision making and Branching in C
C programming Workshop
Variables in C Programming
Introduction to C programming
Input output statement in C
CPU INPUT OUTPUT
Learn C# Programming - Operators
Input And Output
C Language (All Concept)
C Programming
datatypes and variables in c language
pointer, structure ,union and intro to file handling
Mesics lecture 5 input – output in ‘c’
C programming(Part 1)
Ad

Viewers also liked (20)

DOC
Campbell Investments Limited Introduces Two New Multi-Asset Funds
PDF
Poca 140318195851-phpapp02
PDF
Fuzzy motor
PDF
Presentation
PDF
CALIBRATION OF VEHICLE EMISSIONS-SPEED RELATIONSHIPS FOR THE GREATER CAIRO ROADS
PDF
PARAMETRIC INVESTIGATIONS ON THE FLOW CHARACTERISTICS OF A CLOSED LOOP PULSAT...
PDF
Curriculum Vitae (2016)
PDF
Felicitaciones
DOC
Comunicado n° 3 2
PPTX
SeniorDesign_PosterTemplateV1.2-1
PPTX
Shot list
PDF
Crónicas de la ínsula 31 10
PPTX
Project Update - Earth Towne
PDF
CompTIA A+ ce certificate (1)
PPTX
Cmp2412 programming principles
PDF
ACSN Issue #9
PPTX
Presentation1
PDF
Reumatismo tratamiento
PDF
Pós-Graduação Gestão de Negócios Online
Campbell Investments Limited Introduces Two New Multi-Asset Funds
Poca 140318195851-phpapp02
Fuzzy motor
Presentation
CALIBRATION OF VEHICLE EMISSIONS-SPEED RELATIONSHIPS FOR THE GREATER CAIRO ROADS
PARAMETRIC INVESTIGATIONS ON THE FLOW CHARACTERISTICS OF A CLOSED LOOP PULSAT...
Curriculum Vitae (2016)
Felicitaciones
Comunicado n° 3 2
SeniorDesign_PosterTemplateV1.2-1
Shot list
Crónicas de la ínsula 31 10
Project Update - Earth Towne
CompTIA A+ ce certificate (1)
Cmp2412 programming principles
ACSN Issue #9
Presentation1
Reumatismo tratamiento
Pós-Graduação Gestão de Negócios Online
Ad

Similar to Programming Fundamentals lecture 4 (20)

PPTX
comp 122 Chapter 2.pptx,language semantics
PPT
Introduction to C Programming
PPT
Unit 4 Foc
PDF
C programing Tutorial
PPT
Intro Basics of C language Operators.ppt
PPTX
Introduction%20C.pptx
PPTX
PPTX
C programming language for beginners
PPTX
Unit 2- Module 2.pptx
PPTX
Each n Every topic of C Programming.pptx
PPTX
C_Programming_Language_tutorial__Autosaved_.pptx
PDF
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
PPT
Problem Solving Techniques
PDF
java or oops class not in kerala polytechnic 4rth semester nots j
PPSX
Esoft Metro Campus - Certificate in c / c++ programming
PPTX
C Programming - Basics of c -history of c
PPT
C presentation book
PDF
Reduce course notes class xii
PPSX
C basics 4 std11(GujBoard)
PPTX
unit 1 cpds.pptx
comp 122 Chapter 2.pptx,language semantics
Introduction to C Programming
Unit 4 Foc
C programing Tutorial
Intro Basics of C language Operators.ppt
Introduction%20C.pptx
C programming language for beginners
Unit 2- Module 2.pptx
Each n Every topic of C Programming.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
Problem Solving Techniques
java or oops class not in kerala polytechnic 4rth semester nots j
Esoft Metro Campus - Certificate in c / c++ programming
C Programming - Basics of c -history of c
C presentation book
Reduce course notes class xii
C basics 4 std11(GujBoard)
unit 1 cpds.pptx

More from REHAN IJAZ (14)

DOCX
How to make presentation effective assignment
DOCX
Project code for Project on Student information management system
DOCX
Programming Fundamentals lecture 8
PPTX
Introduction to artificial intelligence lecture 1
DOCX
Programming Fundamentals lecture 7
PPTX
Programming Fundamentals lecture 6
PPTX
Programming Fundamentals lecture 5
PPTX
Programming Fundamentals lecture 3
PPTX
Programming Fundamentals lecture 2
PPTX
Programming Fundamentals lecture 1
PDF
Career development interviews
DOC
importance of Communication in business
DOCX
Porposal on Student information management system
PPTX
Project on Student information management system
How to make presentation effective assignment
Project code for Project on Student information management system
Programming Fundamentals lecture 8
Introduction to artificial intelligence lecture 1
Programming Fundamentals lecture 7
Programming Fundamentals lecture 6
Programming Fundamentals lecture 5
Programming Fundamentals lecture 3
Programming Fundamentals lecture 2
Programming Fundamentals lecture 1
Career development interviews
importance of Communication in business
Porposal on Student information management system
Project on Student information management system

Recently uploaded (20)

DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
Construction Project Organization Group 2.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT
Mechanical Engineering MATERIALS Selection
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Well-logging-methods_new................
PPTX
additive manufacturing of ss316l using mig welding
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
573137875-Attendance-Management-System-original
Construction Project Organization Group 2.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mechanical Engineering MATERIALS Selection
Operating System & Kernel Study Guide-1 - converted.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Well-logging-methods_new................
additive manufacturing of ss316l using mig welding
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf

Programming Fundamentals lecture 4

  • 1. BY REHAN IJAZ 04- Getting Started with C
  • 2. BY REHAN IJAZ C's Character Set C does not use, nor requires the use of, every character found on a modern computer keyboard. The use of most of this set of characters will be discussed throughout the course. The only characters required by the C Programming Language are as follows: character:- It denotes any alphabet, digit or special symbol used to represent information. Use:- These characters can be combined to form variables. C uses variables, operators, keywords and expressions as building blocks to form a basic C program. Character set:- The character set is the fundamental raw material of any language and they are used to represent information. Like natural languages, computer language will also have well defined character set, which is useful to build the programs. The characters in C are grouped into the following two categories: 1. Source characterset a. Alphabets b. Digits c. Special Characters d. White Spaces 2. Execution characterset a. Escape Sequence 1. Source character set ALPHABETS Uppercase letters A-Z Lowercase letters a-z DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 SPECIAL CHARACTERS WHITESPACE CHARACTERS b blank space t horizontal tab v vertical tab r carriage return f form feed n new line
  • 3. BY REHAN IJAZ Back slash ’ Single quote " Double quote ? Question mark 0 Null a Alarm (bell) 2. Execution Character Set Certain ASCII characters are unprintable, which means they are not displayed on the screen or printer. Those characters perform other functions aside from displaying text. Examples are backspacing or moving to a newline . They are used in output statements. Escape sequence usually consists of a backslash and a letter or a combination of digits. An escape sequence is considered as a single character but a valid character constant. These are employed at the time of execution of the program. Execution characters set are always represented by a backslash () followed by a character. Note that each one of character constants represents one character, although they consist of two characters. These characters combinations are called as escape sequence. Escape Sequence Invalid Sequence #include <stdio.h> int main() { printf("Hello, world!"); } Correct Sequence #include <stdio.h> int main() { printf("Hello,nworld!"); }
  • 4. BY REHAN IJAZ More Escape Sequences  Null 0 Null  Alarm (bell) a Beep Sound  Back space b Moves previous position  Horizontal tab t Moves next horizontal tab  New line n Moves next Line  Vertical tab v Moves next vertical tab  Form feed f Moves initial position of next page  Carriage return r Moves beginning of the line  Double quote " Present Double quotes  Single quote ' Present Apostrophe  Question mark ? Present Question Mark  Back slash Present back slash
  • 5. BY REHAN IJAZ C’s Variable  C variable is a named location in a memory where a program can manipulate the data. This location is used to hold the value of the variable.  The value of the C variable may get change in the program.  C variable might be belonging to any of the data type like int, float, char etc. Rules for naming C variable: 1. Variable name must begin with letter or underscore. 2. Variable names are case sensitive 3. They can be constructed with digits, letters. 4. No special symbols are allowed other than underscore. 5. sum, height, _value are some examples for variable name Declaring & initializing C variable:  Variables should be declared in the C program before to use.  Memory space is not allocated for a variable while declaration. It happens only on variable definition.  Variable initialization means assigning a value to the variable. S.No Type Syntax Example 1 Variable declaration data_type variable_name; int x, y, z; char flat, ch; 2 Variable initialization data_type variable_name = value; int x = 50, y = 30; char flag = ‘x’, ch=’l’; Variable types There are three types of variables in C program They are, 1. Local variable 2. Global variable 3. Environment variable
  • 6. BY REHAN IJAZ 1. Example program for local variable in C:  The scope of local variables will be within the function only.  These variables are declared within the function and can’t be accessed outside the function.  In the below example, m and n variables are having scope within the main function only. These are not visible to test function.  Like wise, a and b variables are having scope within the test function only. These are not visible to main function. #include<stdio.h> void test(); int main() { int m = 22, n = 44; printf(“nvalues : m = %d and n = %d”, m, n); test(); } void test() { int a = 50, b = 80; printf(“nvalues : a = %d and b = %d”, a, b); } Output: values : m = 22 and n = 44 values : a = 50 and b = 80
  • 7. BY REHAN IJAZ 2. Example program for global variable in C:  The scope of global variables will be throughout the program. These variables can be accessed from anywhere in the program.  This variable is defined outside the main function. So that, this variable is visible to main function and all other sub functions. #include<stdio.h> void test();int m = 22, n = 44; int a = 50, b = 80; int main() { printf(“All variables are accessed from main function”); printf(“nvalues: m=%d:n=%d:a=%d:b=%d”, m,n,a,b); test(); } void test() { printf(“nnAll variables are accessed from” ” test function”); printf(“nvalues: m=%d:n=%d:a=%d:b=%d”, m,n,a,b); } Output: All variables are accessed from main function values : m = 22 : n = 44 : a = 50 : b = 80 All variables are accessed from test function values : m = 22 : n = 44 : a = 50 : b = 80
  • 8. BY REHAN IJAZ C’s Identifiers Identifiers in C language:  Each program elements in a C program are given a name called identifiers.  Names given to identify Variables, functions and arrays are examples for identifiers. eg. x is a name given to integer variable in above program. Rules for constructing identifier name in C: 1. First character should be an alphabet or underscore. 2. Succeeding characters might be digits or letter. 3. Punctuation and special characters aren’t allowed except underscore. 4. Identifiers should not be keywords.
  • 9. BY REHAN IJAZ C’s Key words  Keywords are pre-defined words in a C compiler.  Each keyword is meant to perform a specific function in a C program.  Since keywords are referred names for compiler, they can’t be used as variable name. C language supports 32 keywords which are given below. auto double int struct const float short unsigned break else long switch continue for signed void case enum register typedef default goto sizeof volatile char extern return union do if static while