Course Title: Structured Programming Language Course Code: CSE 1201
Presented by: Presented for:
Stein Joachim Rebeiro (202120001) Abul Hasnat Md. Saiful Islam,
Zubayer Farazi (202120003) Associate Professor,
Raisa Fabiha (202120004) Chairman, Department of CSE,
Notre Dame University, Bangladesh
Department: Computer Science & Engineering
Programing Language Defination, Application
History of C Programing Language
Improtance of Flow Chart
Flow Chart, Pseudo Code (Algorithm Example)
Control Structure (loop) / break / Continue
Decision Making & Branching
Operator, Explanation with Appropriate Code
Variable, Constants, Identifier, Rules
PROGRAMMING LANGUAGE DEFINITION:
• A FORMAL LANGUAGE COMPRISING A SET OF INSTRUCTIONS
• THIS LANGUAGE PROVIDES A WAY OF TELLING A COMPUTER WHAT
OPERATIONS TO PERFORM.
• EACH PROGRAMMING LANGUAGE HAS A DIFFERENT SET OF SYNTAX
• USED TO CREATE PROGRAMS THAT CONTROL THE BEHAVIOR OF A
TYPES OF LANGUAGES:
Low level language High level language
Machine Language Assembly Language
C,C++, Fortran, Java,
Python, Basic, Pascal….
The native language of the computer
0 and 1 these two binary digits are used to write this language
Little easier than machine language
Replaces 1 and 0s with English instructions
Use symbols or Collection of mnemonic codes
It has command like: ADD, MUL, DIV, INP etc.
High Level Language:
Close to human language
Easy to learn
C, C++, Fortran, Cobol etc. uses compiler
Python, Basic etc. uses interpreter
Applications of Programming Language:
• To create software
• Software can be made for calculator or to do
• To create web applications
• In software development
• Games and animations with 3d effects
• For game design
HISTORY OF C PROGRAMMING LANGUAGE:
• C was evolved from ALGOL, BCPL and B
• In 1972 Dennis Ritchie at Bell Laboratories writes C
• It was developed along with the UNIX operating system
• Added new features and concept like “data types”
• In December 1989 American National Standards Institute (ANSI) approved a
version of C which is now known as ANSI C
HISTORY OF C PROGRAMMING LANGUAGE:
Language Developed Year Developed By
ALGOL 1960 International Group
BCPL 1967 Martin Richards
B 1970 Ken Thompson
C 1972 Dennis Ritchie
K&R C 1978 Kernighan and Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standard Committee
C11 2011 Standard Committee
• Diagrammatic representation of logic for solving task
• Drawn using boxes of different shapes with lines connecting them to show the
flow of control
• Make logic of program clearer in a visual form
• Diagrammatic representation forms a common medium of communication
• Drawn using different kinds of symbols.
• Consists of short, readable and formally-styled English language used for explaining
• Does not include details like variable declarations, subroutines etc.
• Short-hand way of describing computer program
• Not based on any programming language
• Uses structured constructs of programming language but is not machine readable
• Cannot be compiled or executed
• No standard for syntax of pseudo code exists
• Ordered sequence of finite, well defined, unambiguous instructions for
completing a task.
• English-like representation of logic to solve problem
• Step-by-step procedure for solving problem
• For a particular task, different algorithms can be written
**We need to select an algorithm based on advantages and disadvantages.
Different Algorithms would typically lead to trade off between memory requirements and
• In programming, a variable is a container (storage area) to hold data.
• To indicate the storage area, each variable should be given a unique name . Variable
names are just the symbolic representation of a memory location.
• Each variable in C has a specific type, which determines the size and layout of the
variable's memory; the range of values that can be stored within that memory; and the
set of operations that can be applied to the variable.
• The name of a variable can be composed of letters, digits, and the underscore character.
It must begin with either a letter or an underscore. Upper and lowercase letters are
distinct because C is case-sensitive.
RULES OF VARIABLES:
• A variable name can only have letters (both uppercase and lowercase letters), digits, dollar sign($) and
• The first letter of a variable should be either a letter or an underscore.
• Keywords, ‘&’, Variable name starting with numbers, hyphen(-) ; no special symbols are valid.
Note: We should always try to give meaningful names to variables. For example: First Name is a better
variable name than fn.
**C is a strongly typed language. This means that the variable type cannot be changed once it is
• C Constants are also like normal variables. But, only difference is, their values can
not be modified by the program once they are defined.
• Constants refer to fixed values. They are also called as literals
• Constants may be belonging to any of the data type.
RULES OF CONSTANTS:
• By “const” keyword or by “#define” preprocessor directive, a constant is declared
in C program.
• It can either be positive or negative. If no sign is declared, then the constant is
assumed to be positive.
• No commas or blanks are allowed within a constant.
• Character constant is a single alphabet, a single digit or a single special symbol
enclosed within single quotes.
• The allowable range for integer constants is -32768 to 32767.
• If we try to change constant values after defining in C program, it will show error.
• Identifier refers to name given to entities such as variables, functions, structures
etc. Variable and identifiers are almost the same but identifier can be used in a
larger scale. Such as- “Array”.
• Identifiers must be unique. They are created to give a unique name to an entity to
identify it during the execution of the program. For example:
int money; double Balance;
Here, money and Balance are identifiers.
• Also identifier names must be different from keywords. We cannot use `int` as an
identifier because int is a keyword.
RULES OF IDENTIFIERS:
• A valid identifier can have letters (both uppercase and lowercase letters), digits and
• The first letter of an identifier should be either a letter or an underscore.
• Keywords like int, while etc. cannot be used as identifiers.
• There is no rule on how long an identifier can be.
**Any name can be chosen as an identifier if we follow the above rules. However, giving
meaningful names are recommended as identifiers that make sense.**
EXAMPLE OF VARIABLE, CONSTANT & IDENTIFIER:
If we use variable_1 then it will become an array. Even then
it will be consider as an identifier but we cannot declare it as
a variable anymore. And this is the difference between
identifier & variable.
• Data types in c refer to an extensive system used for declaring variables or
functions of different types. The type of a variable determines how much space it
occupies in storage and how the bit pattern stored is interpreted.
• It determines the type and size of data associated with variables. For example:
Here, myVar is a variable of int (integer) type. The size of int is 4 bytes.
• Data types are used to define a variable before to use in a program.
• Size of variable, constant and array are determined by data types.
An operator is a symbol that tells the
computer to perform certain mathematical or
These operators are used in programs to
manipulate data and variables.
TYPES OF OPERATOR:
• Arithmetic operators
• Relation operators
• Logical operators
• Assignment operators
• Increment and decrement operators
• Conditional operators
• Bitwise operators
• Special operators
Arithmetic operator are used to perform numeric calculations
among the values.
+ Addition or unary plus
- Subtraction or unary minus
% Modulo division
printf(“Enter two integer value:”);
Enter two integer value:20 10
Relational operators are used to compare two quantities and take certain decision depending
on their relation.
• If the relation is true it returns one.
• If the relation is false it returns zero.
< is less than
<= is less than or equal
> is greater then
>= is greater then or equal
== is equal to
!= is not equal to
printf("The number of X,Y,Zn");
//is x greater than y
//is z less than y
//is y greater than or equal z
//is x equal y
//is y not equal to z
The number of X,Y,Z
Logical operator are used for testing more than one condition and making decisions.
&& Logical AND
|| Logical OR
! Logical NOT
printf("Enter the numbers of X,Y,Zn");
sum=(x!=z) && (x>y);
printf("(x!=z) && (x>y) is %dn",sum);
sum=(x>=y) || (y<z);
printf("(x>=y) || (y<z) is %dn",sum);
printf("(x!=y) is %dn",sum);
Enter the numbers of X,Y,Z
(x!=z) && (x>y) is 0
(x>=y) || (y<z) is 0
(x!=y) is 1
• These operator are used for assigning the result of an expression to a variable.
Statement of simple assignment
Statement with shorthand operator
a =a+1 a + = 1
printf(“Enter three integer number:n”);
Enter three integer number:
5 10 15
INCREMENT AND DECREMENT OPERATORS:
C allows two very useful operators. These are the increment and decrement operators:
++ and --
• The operator ++ adds one to the operands.
• The operator – subtracts one from the operand.
**Both are unary operators and can be used as pre or post increment or decrement.
printf(“Enter three integer number:n”);
Enter three integer
4 5 6
Where exp1,exp2,exp3 are expressions.
?: (ternary operator)
These conditional operator are used to construct
conditional expressions of the form.
printf("Enter two numbers : n");
result=(num1>num2) ? num1 : num2;
printf("The maximum number between %d and %d is %dn",num1,num2,result);
Enter two numbers :
number between 10
and 20 is 20
• These operator works on bit level
• Applied to integer only.
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
<< Shift left
>> Shift right
C supports some special operators such as-
• comma operator
• sizeof operator
• pointer operators comma
• The operator is used to combine related expressions.
• A comma linked list of expressions are evaluated left to right and the value of right
most expression is the value of combined expression.
SIZE OF OPERATOR:
Sizeof is an operator used to return the number of bytes the operand occupies.
DECISION MAKING STATEMENT:
• Also known as control structure
• Controls the flow of execution
• Execute program until a specific control is met
• One of the most important parts in programming
TYPES OF DECISION-MAKING STATEMENT:
If If-else If-else if Nested if
• The expression must be evaluating to true or false.
• The “Statement” can be a group or in braces.
printf(“Enter any number:”);
printf(“You can marry now”);
Enter any number:
You can marry now
• An extension version of if statement.
• Generally in the form of if (test expression)
If (test expression)
true block statement
false block statement
printf("Enter any two number: n");
printf("They are equal");
printf("They are not equal");
Enter any two number:
They are not equal
• It is used to give series of decision.
Else if (condition 2)
Statement when all condition are false.
NESTED IF-ELSE STATEMENT:
• New block or if else statement defined in exiting if or else block statement.
• Multi-way decision statement
• Tests the value of a given variable against a list of case values.
• When a match is found, a block of statements associated with that case is executed.
Case<value1>: <sequence of statements>;
Case<value2>: <sequence of the
Case<value3>: <sequence of statements>;
Default: <sequence of statements>;
printf("Enter any number :n");
switch(num % 2)
printf("This number is even number");
printf("This number is odd number");
Enter any number:
This number is even number
Loops are used in programming to repeat a specific block until some end
condition is met.
There are three loops in c programming.
do while loop
• The syntax of a for loop is:
for(initialization ; condition; variable update)
//code to execute while the condition is true
DO WHILE LOOP:
• The syntax of a do while loop is:
//body of the loop
printf("Summation of ODD numbers: %dn",s);
Summation of ODD numbers: 25
• The break statement terminates the loop immediately when it is
• The break is used with decision making statement such as if else
• Syntax of the break statement:
for (num =100; num>=10; num --)
printf(“num: %dn", num);
printf("Out of for-loop");
Out of for-loop
• The continue statement skips some statements inside loop.
• The continue statement is used with decision making statement such as if
• Syntax of continue statements:
printf("%d ", j);
0 1 2 3 4 5 6 8 9