• Overview of C: History and importance C
• Algorithm :- ” A set of finite rules or instructions to be followed in
calculations or other problem-solving operations. ”
Therefore Algorithm refers to a sequence of finite steps to solve a
particular problem.
A set of steps that generates a finite sequence of elementary
computational operations leading to the solution of a given problem
is called an algorithm.
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
1
Example of algorithm for addition of two number
Step 1. INPUT TO A, B
Step 2. S ← A+B --(Store the sum of the values in A and B in S)
Step 3. PRINT S --(Show the sum obtained in Step 2)
Step 4. STOP
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
2
• Flowchart :- A flowchart is a blueprint that pictorially represents the algorithm and its steps.
• Formally speaking, a flowchart is a diagrammatic representation of the steps of an algorithm.
• In a flowchart, boxes of different shapes are used to denote different types of operations.
These boxes are then connected by lines with arrows denoting the flow or direction to which
one should proceed to know the next step.
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
3
Example of flowchart
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
4
C PROGRAMFOR ADDITIONOFTWO NUMBER
# include<stdio.h>
#include<math.h>
Int main ()
{
int a , b , c ;
a = 5;
b = 7;
c = a + b;
printf(“%d”, c )
return 0;
}
10/8/2024
Fundamentals
of
Programming
languages
5
• Overview of C: History and importance C
• Overview of C:
• It is a general-purpose, procedure-oriented programming language.
• It is both machine-independent and structured. C is a high-level programming language
developed by Dennis Ritchie in the early 1970s.
• It is now one of the most popular and influential programming languages worldwide.
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
6
• History C
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
7
• Importance of C :
UNIT –I Introduction to Program Planning & C Programming
•C allows for direct memory manipulation and low-level
access to system resources
Efficiency
•C code can be easily ported to different platforms & wide
availability of compilers and libraries.
Portability
•C is known for its fast execution speed, making it suitable
for developing performance-critical applications
Speed
•C gives programmers fine-grained control over memory
management and system resources
Control
•C code can be easily integrated with code written in other
languages like C++, Java, and Python
Compatibility
10/8/2024
Fundamentals
of
Programming
languages
8
• Character Set :
character set refers to a set of all the valid characters that we can use in the source program
for forming words, expressions, and numbers
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
9
Tokens in C :
It is a smallest individual element of the C programming language that is meaningful to the compiler.
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
10
• Keywords :
These are words that have special meaning to the C compiler.
UNIT –I Introduction to Program Planning & C Programming
auto break case char const
continue default do double else
enum extern float for goto
if int long register return
short signed sizeof static struct
switch typedef union unsigned void
volatile while
10/8/2024
Fundamentals
of
Programming
languages
11
• Identifiers :
These are unique names that are assigned to variables, structs,
functions, and other entities.
UNIT –I Introduction to Program Planning & C Programming
Sr.
No
Identifier Keyword
1 An identifier is a unique name created
by the programmer to define a
variable, structure, class, or function.
Keywords are restricted words with a definite,
predetermined meaning. Any programme
statement may be defined with the aid of
keywords.
2
A keyword always starts in lowercase.
The initial character in the identification can
be capitalized, lowercase, or start with an
underscore.
3 It can only have alphabetical
characters.
It can have numbers, alphabetical characters,
and underscores.
4 Examples of keywords are double, int,
auto, char, break, and many others.
Examples of IDs are test, count1, high speed,
etc.
10/8/2024
Fundamentals
of
Programming
languages
12
• Constants :
It is a value that remains constant throughout the program and
cannot be changed during program execution..
UNIT –I Introduction to Program Planning & C Programming
Constants
Primary
Integer
Real
Character
Secondary
Array
Pointer
Structure
Union
Enum , etc
10/8/2024
Fundamentals
of
Programming
languages
13
• Variables :
It is the name associated with some memory location to store data
of different types.
C Variable Syntax
Data type variable name = value;
or
data type variable_name1, variable_name2;
Example
Int var; // integer variable
char a; // character variable
float fff; // float variables
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
14
UNIT –I Introduction to Program Planning & C Programming
• Data types :
• It specifies the type of data that the variable can store like integer, character, floating,
double, etc.
10/8/2024
Fundamentals
of
Programming
languages
15
UNIT –I Introduction to Program Planning & C Programming
• Declaration of variables:
• The main purpose of variable declaration is to store the required data in the memory
location in the form of variables so that we can use them in our program to perform any
operation or task.
• E xample:
10/8/2024
Fundamentals
of
Programming
languages
16
UNIT –I Introduction to Program Planning & C Programming
• Storage Classes in C
• C Storage Classes are used to describe the features of a variable/function.
• These features basically include the scope, visibility, and lifetime which help us to trace the existence
of a particular variable during the runtime of a program.
10/8/2024
Fundamentals
of
Programming
languages
17
UNIT –I Introduction to Program Planning & C Programming
• Assigning Values to variables:
 “Assigning a value to a variable” means writing a value to the variable.
This process involves four entities:
• A data type
• A variable
• The simple assignment operator (=)
• The value that will be copied to the variable.
10/8/2024
Fundamentals
of
Programming
languages
18
UNIT –I Introduction to Program Planning & C Programming
• Assigning Values to variables:
• Here:
• “ int ” is the data type.
• “ a ” is the variable.
• “ = " is the operator.
• “ 4 ” is the value.
“ int a = 4 ; ”
10/8/2024
Fundamentals
of
Programming
languages
19
UNIT –I Introduction to Program Planning & C Programming
• Defining Symbolic Constants:
• Labels/names that represent fixed values that never change during the course of a
program.
• Syntax for Creating Symbolic Constants
#define symbolic_constant_name value_of_the_constant
• Symbolic Constants Examples
10/8/2024
Fundamentals
of
Programming
languages
20
UNIT –I Introduction to Program Planning & C Programming
• declaring a Variable as Constant:
• To create a constant in C, use the const keyword followed by a data type and a variable
name.
• example:
const int MAX_VALUE = 100;
This will create a constant variable named MAX_VALUE with a value of 100.
10/8/2024
Fundamentals
of
Programming
languages
21
• Comparison between constants and variables :
UNIT –I Introduction to Program Planning & C Programming
Sr.
No
Constants Variables
1 A constant does not change its
value as the equation is solved.
A variable, on the other hand, changes
its value depending on the equation.
2 Constants are usually written in
numbers(whether fractions,
integers, decimals or real
numbers).
Variables are written as letters or
symbols.
3 Constants usually represent the
known values in an equation or
expression.
Variables, on the other hand,
represent unknown values.
4 Constants have fixed face
values.
Variables do not have a fixed face
value..
10/8/2024
Fundamentals
of
Programming
languages
22
Declaring a Variable as Volatile:
• When a variable is declared as volatile, it indicates to the compiler
that the variable’s value may change at any time without any
action being taken by the code the compiler finds nearby.
• The syntax for using the volatile keyword in C is as follows:
volatile data_type variable_name;
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
23
Example of Declaring a Variable as Volatile:
UNIT –I Introduction to Program Planning & C Programming
10/8/2024
Fundamentals
of
Programming
languages
24

Fundamental of Programming Language UNIT-I

  • 1.
    • Overview ofC: History and importance C • Algorithm :- ” A set of finite rules or instructions to be followed in calculations or other problem-solving operations. ” Therefore Algorithm refers to a sequence of finite steps to solve a particular problem. A set of steps that generates a finite sequence of elementary computational operations leading to the solution of a given problem is called an algorithm. UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 1
  • 2.
    Example of algorithmfor addition of two number Step 1. INPUT TO A, B Step 2. S ← A+B --(Store the sum of the values in A and B in S) Step 3. PRINT S --(Show the sum obtained in Step 2) Step 4. STOP UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 2
  • 3.
    • Flowchart :-A flowchart is a blueprint that pictorially represents the algorithm and its steps. • Formally speaking, a flowchart is a diagrammatic representation of the steps of an algorithm. • In a flowchart, boxes of different shapes are used to denote different types of operations. These boxes are then connected by lines with arrows denoting the flow or direction to which one should proceed to know the next step. UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 3
  • 4.
    Example of flowchart UNIT–I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 4
  • 5.
    C PROGRAMFOR ADDITIONOFTWONUMBER # include<stdio.h> #include<math.h> Int main () { int a , b , c ; a = 5; b = 7; c = a + b; printf(“%d”, c ) return 0; } 10/8/2024 Fundamentals of Programming languages 5
  • 6.
    • Overview ofC: History and importance C • Overview of C: • It is a general-purpose, procedure-oriented programming language. • It is both machine-independent and structured. C is a high-level programming language developed by Dennis Ritchie in the early 1970s. • It is now one of the most popular and influential programming languages worldwide. UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 6
  • 7.
    • History C UNIT–I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 7
  • 8.
    • Importance ofC : UNIT –I Introduction to Program Planning & C Programming •C allows for direct memory manipulation and low-level access to system resources Efficiency •C code can be easily ported to different platforms & wide availability of compilers and libraries. Portability •C is known for its fast execution speed, making it suitable for developing performance-critical applications Speed •C gives programmers fine-grained control over memory management and system resources Control •C code can be easily integrated with code written in other languages like C++, Java, and Python Compatibility 10/8/2024 Fundamentals of Programming languages 8
  • 9.
    • Character Set: character set refers to a set of all the valid characters that we can use in the source program for forming words, expressions, and numbers UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 9
  • 10.
    Tokens in C: It is a smallest individual element of the C programming language that is meaningful to the compiler. UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 10
  • 11.
    • Keywords : Theseare words that have special meaning to the C compiler. UNIT –I Introduction to Program Planning & C Programming auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while 10/8/2024 Fundamentals of Programming languages 11
  • 12.
    • Identifiers : Theseare unique names that are assigned to variables, structs, functions, and other entities. UNIT –I Introduction to Program Planning & C Programming Sr. No Identifier Keyword 1 An identifier is a unique name created by the programmer to define a variable, structure, class, or function. Keywords are restricted words with a definite, predetermined meaning. Any programme statement may be defined with the aid of keywords. 2 A keyword always starts in lowercase. The initial character in the identification can be capitalized, lowercase, or start with an underscore. 3 It can only have alphabetical characters. It can have numbers, alphabetical characters, and underscores. 4 Examples of keywords are double, int, auto, char, break, and many others. Examples of IDs are test, count1, high speed, etc. 10/8/2024 Fundamentals of Programming languages 12
  • 13.
    • Constants : Itis a value that remains constant throughout the program and cannot be changed during program execution.. UNIT –I Introduction to Program Planning & C Programming Constants Primary Integer Real Character Secondary Array Pointer Structure Union Enum , etc 10/8/2024 Fundamentals of Programming languages 13
  • 14.
    • Variables : Itis the name associated with some memory location to store data of different types. C Variable Syntax Data type variable name = value; or data type variable_name1, variable_name2; Example Int var; // integer variable char a; // character variable float fff; // float variables UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 14
  • 15.
    UNIT –I Introductionto Program Planning & C Programming • Data types : • It specifies the type of data that the variable can store like integer, character, floating, double, etc. 10/8/2024 Fundamentals of Programming languages 15
  • 16.
    UNIT –I Introductionto Program Planning & C Programming • Declaration of variables: • The main purpose of variable declaration is to store the required data in the memory location in the form of variables so that we can use them in our program to perform any operation or task. • E xample: 10/8/2024 Fundamentals of Programming languages 16
  • 17.
    UNIT –I Introductionto Program Planning & C Programming • Storage Classes in C • C Storage Classes are used to describe the features of a variable/function. • These features basically include the scope, visibility, and lifetime which help us to trace the existence of a particular variable during the runtime of a program. 10/8/2024 Fundamentals of Programming languages 17
  • 18.
    UNIT –I Introductionto Program Planning & C Programming • Assigning Values to variables:  “Assigning a value to a variable” means writing a value to the variable. This process involves four entities: • A data type • A variable • The simple assignment operator (=) • The value that will be copied to the variable. 10/8/2024 Fundamentals of Programming languages 18
  • 19.
    UNIT –I Introductionto Program Planning & C Programming • Assigning Values to variables: • Here: • “ int ” is the data type. • “ a ” is the variable. • “ = " is the operator. • “ 4 ” is the value. “ int a = 4 ; ” 10/8/2024 Fundamentals of Programming languages 19
  • 20.
    UNIT –I Introductionto Program Planning & C Programming • Defining Symbolic Constants: • Labels/names that represent fixed values that never change during the course of a program. • Syntax for Creating Symbolic Constants #define symbolic_constant_name value_of_the_constant • Symbolic Constants Examples 10/8/2024 Fundamentals of Programming languages 20
  • 21.
    UNIT –I Introductionto Program Planning & C Programming • declaring a Variable as Constant: • To create a constant in C, use the const keyword followed by a data type and a variable name. • example: const int MAX_VALUE = 100; This will create a constant variable named MAX_VALUE with a value of 100. 10/8/2024 Fundamentals of Programming languages 21
  • 22.
    • Comparison betweenconstants and variables : UNIT –I Introduction to Program Planning & C Programming Sr. No Constants Variables 1 A constant does not change its value as the equation is solved. A variable, on the other hand, changes its value depending on the equation. 2 Constants are usually written in numbers(whether fractions, integers, decimals or real numbers). Variables are written as letters or symbols. 3 Constants usually represent the known values in an equation or expression. Variables, on the other hand, represent unknown values. 4 Constants have fixed face values. Variables do not have a fixed face value.. 10/8/2024 Fundamentals of Programming languages 22
  • 23.
    Declaring a Variableas Volatile: • When a variable is declared as volatile, it indicates to the compiler that the variable’s value may change at any time without any action being taken by the code the compiler finds nearby. • The syntax for using the volatile keyword in C is as follows: volatile data_type variable_name; UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 23
  • 24.
    Example of Declaringa Variable as Volatile: UNIT –I Introduction to Program Planning & C Programming 10/8/2024 Fundamentals of Programming languages 24