Professional Documents
Culture Documents
BASICS OF C
What will you learn?
What is Programming Language
Types of Programming Languages
Introduction to C Language
Structure of C Program
Compilation and Execution of C Programs
WHAT IS PROGRAMMING ?
Programming is letting the computer
to learn
how to do the things.
-------------------------------------
Programming is giving training to computer
to do things
as it is non – intelligent body
------------------------------------
Programming is meant for
solving the problems by the Computer
TYPES OF PROGRAMMING LANGUAGES
To write a program for a computer, we must use a computer
language. Over the years computer languages have evolved from
machine languages to natural languages.
Each computer has its own machine language, which is made of streams
of 0’s and 1’s.
It appears that there will be yet another ANSI C standard officially dated 1999 or
in the early 2000 years; it is currently known as "C99."
Learning Analogy for C
Grammar
Rules
Learning Analogy for C
Character Programs
Tokens Statements
Set
Syntax
Rules
CREATING AND RUNNING PROGRAMS
Library
Library Files
Files
TOKENS OF C
1. Literals
2. Identifiers
3. Keywords
4. Operators
5. Special Characters
LITERAL CONSTANTS
The constants refer to fixed values that the program may not alter during its
execution. These fixed values are also called literals.
Constants can be of any of the basic data types like an integer literal, a floating
literal, a character literal, or a string literal.
Integer literals
Floating-point literals
A floating-point literal has an integer part, a decimal point, a fractional part, and an
exponent part. You can represent floating point literals either in decimal form or
exponential form.
Character literals are enclosed in single quotes, e.g., 'x' and can be stored in a simple
String literals
String literals or constants are enclosed in double quotes "". A string contains
characters that are similar to character literals: plain characters, escape sequences,
Examples:
"hello, dear"
"hello, dear"
VARIABLES
A variable is defined as a meaningful name given to the data storage
location in the computer memory. A variable value can be allowed to
change during the execution of a program.
<datatype> <variable_name>;
Example:
1. int rollno;
2. char grade;
3. float temperature;
DATA TYPES
BASIC DATA TYPES IN C
Data types are used to specify two things to the compiler:
Control string may also contain text, captions, identifiers or any other
text that is to be readable.
INPUT AND OUTPUT STATEMENTS IN C
INPUT Statement:
The function scanf ( ) is used to read the data from the keyboard. This
function takes the text from keyboards and formats the data according to the
format specified in the control string and then stores the data in the
variables.
The control string specified the type and format of the data that has to be
obtained from the keyboard and stored in the memory locations pointed by
the arguments arg1, arg2, arg3,….., argN.
scanf(“%d”, &x);
printf(“%d”, x);
EXAMPLES:
float x;
scanf(“%f”, &x);
printf(“%f”, x);
EXAMPLES:
It is possible to read and write multiple variables at the same time
char x;
float y;
int z;
scanf(“%c”, &x);
printf(“%c”, x);
OPERATORS OF C
An Operator is a symbol that performs some mathematical or logical
operation. In C there are different categories of Operators:
1. Arithmetic ( +, -, *, /, %)
7. Conditional (? : )
8. Special Operators