Lesson 01 - C Introduction - Data Types & Variables
Lesson 01 - C Introduction - Data Types & Variables
First C Program
First C Program
Variables, Constants
Identifier Names
Data Types
7/19/2022 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 2
Section 1
HISTORY OF C, ABOUT C
History of C
Evolved from two other programming languages
• BCPL and B
– “Typeless” languages
Dennis Ritchie (Bell Laboratories)
• Added data typing, other features
Development language of UNIX
Hardware independent
• Portable programs
1989: ANSI standard
1990: ANSI and ISO standard published
• ANSI/ISO 9899: 1990
C has 32 keywords
These keywords combined with a formal syntax form a C programming
language
Rules to be followed for all programs written in C:
Compiler converts a
C program into an
executable.
There are four phases
for a C program to
become an
executable:
1- Pre-processing
2- Compilation
3- Assembly
4- Linking
Memory
Data 15
15
Examples
5 numeric / integer constant
5.3 numeric / float constant
‘Black’ string constant
‘C’ Character constant
Singular!
One character defined character set.
Surrounded on the single quotation mark.
Examples:
‘A’
‘a’
‘$’
‘4’
7/19/2022 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 19
String Constants
Numbers
Whole numbers. For example, 10 or 178993455
Real numbers. For example, 15.22 or 15463452.25
Positive numbers
Negative numbers
Names. For example, John
Logical values. For example, Y or N
• A data type describes the kind of data that will fit into a variable.
• For example, the data type int would precede the name varName
Datatype variableName
int varName
float num;
char gender;
gender='M';
main ()
{
char abc; /*abc of type character */
int xyz; /*xyz of type integer */
float length; /*length of type float */
double area; /*area of type double */
long liteyrs; /*liteyrs of type long int */
short arm; /*arm of type short integer*/
}