SlideShare a Scribd company logo
1 of 71
Course Title: Structured Programming Language Course Code: CSE 1201
Batch: CSE-14
Trimester: Fall-2020
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
Data Type
Variable, Constants, Identifier, Rules
TOPICS:
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
RULES
• USED TO CREATE PROGRAMS THAT CONTROL THE BEHAVIOR OF A
MACHINE
TYPES OF LANGUAGES:
Programming language
Low level language High level language
Machine Language Assembly Language
C,C++, Fortran, Java,
Python, Basic, Pascal….
Machine language:
 The native language of the computer
 0 and 1 these two binary digits are used to write this language
Assembly 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
mathematical problems
• 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
FLOW CHART:
• 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.
BASIC FLOW CHART SYMBOLS, NAME & FUNCTION:
CONTROL STRUCTURE OF FLOW CHART:
EXAMPLES OF FLOW CHART:
IMPORTANCE OF FLOW CHART:
A Flowchart -
• shows logic of an algorithm
• emphasizes individual steps and their interconnections
• Helps to control flow from one action to the next
Stein
Joachim
Reberio
PSEUDO CODE:
• Consists of short, readable and formally-styled English language used for explaining
an algorithm.
• 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
ALGORITHM:
• 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
execution.
Example of Algorithm with Flow Chart:
VARIABLES:
• 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
underscore.
• 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
declared.**
CONSTANTS:
• 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:
• 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
underscores.
• 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[5] 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:
• 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:
int myVar;
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.
BASIC DATA TYPES:
RANGE AND SIZE OF DIFFERENT DATA TYPES:
EXAMPLE OF DATA TYPE:
Input: Output:
Zubayer
Farazi
OPERATOR:
 An operator is a symbol that tells the
computer to perform certain mathematical or
logical manipulations.
 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 OPERATORS:
 Arithmetic operator are used to perform numeric calculations
among the values.
Operators Meaning
+ Addition or unary plus
- Subtraction or unary minus
* Multiplication
/ Division
% Modulo division
EXAMPLE:
main()
{
int a,b,add,sub,mul,div,mod;
printf(“Enter two integer value:”);
scanf(“%d%d”,&a,&b);
add=a+b;
sub=a-b;
mul=a*b;
div=a/b;
mod=a%b;
Printf(“Summation=%d”,add);
Printf(“subtract=%d”,sub);
Printf(“Multiplication=%d”,mul);
Printf(“Division=%d”,div);
Printf(“Module=%d”,mod);
}
Enter two integer value:20 10
Summation=30
subtract=10
Multiplication=200
Division=2
Module=0
Output:
RELATION OPERATOR:
 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.
Operator Meaning
< is less than
<= is less than or equal
> is greater then
>= is greater then or equal
== is equal to
!= is not equal to
EXAMPLE:
main()
{
int x=12,y=14,z=12;
printf("The number of X,Y,Zn");
//is x greater than y
printf("x>y=%dn",x>y);
//is z less than y
printf("x<y=%dn",x<y);
//is y greater than or equal z
printf("y>=z=%dn",y>z);
//is x equal y
printf("x==y=%dn",x==y);
//is y not equal to z
printf("y!=z=%d",y!=z);
}
The number of X,Y,Z
x>y=0
x<y=1
y>=z=1
x==y=0
y!=z=1
Output:
LOGICAL OPERATOR:
 Logical operator are used for testing more than one condition and making decisions.
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
EXAMPLE:
main()
{
int x=12,y=15,z=13,sum;
printf("Enter the numbers of X,Y,Zn");
//logical And
sum=(x!=z) && (x>y);
printf("(x!=z) && (x>y) is %dn",sum);
//logical Or
sum=(x>=y) || (y<z);
printf("(x>=y) || (y<z) is %dn",sum);
//Logical Not
sum=(x!=y);
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
Output:
ASSIGNMENT OPERATOR:
• These operator are used for assigning the result of an expression to a variable.
• b=a
Statement of simple assignment
operator
Statement with shorthand operator
a =a+1 a + = 1
a=a-1 a-=1
a=a*(n+1) a*=(n+1)
a=a/(n+1) a/=(n+1)
a=a%b a%=b
EXAMPLE:
main()
{
int a,b,c;
printf(“Enter three integer number:n”);
scanf(“%d%d%d”,&a,&b,&c);
printf(“value=%dn”,c+=b);
printf(“value=%dn”,c-=b);
printf(“value=%dn”,c*=b);
printf(“value=%dn”,c/=b);
printf(“value=%dn”,c%=b);
}
Output:
Enter three integer number:
5 10 15
value=25
value=15
value=150
value=15
value=5
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.
EXAMPLE:
main()
{
int a,b,c;
printf(“Enter three integer number:n”);
scanf(“%d%d%d”,&a,&b,&c);
printf(“value=%dn”,c=++a);
printf(“value=%dn”,c=a++);
printf(“value=%dn”,c=--a);
printf(“value=%dn”,c=a--);
}
Output:
Enter three integer
number:
4 5 6
value=5
value=5
value=5
value=5
CONDITIONAL OPERATORS:
Syntax:
exp1?exp2:exp3
Where exp1,exp2,exp3 are expressions.
Operator:
?: (ternary operator)
 These conditional operator are used to construct
conditional expressions of the form.
EXAMPLE:
main()
{
int num1,num2,result;
printf("Enter two numbers : n");
scanf("%d%d",&num1,&num2);
result=(num1>num2) ? num1 : num2;
printf("The maximum number between %d and %d is %dn",num1,num2,result);
}
Enter two numbers :
10
20
The maximum
number between 10
and 20 is 20
Output:
BITWISE OPERATORS:
• These operator works on bit level
• Applied to integer only.
operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
<< Shift left
>> Shift right
SPECIAL OPERATORS:
C supports some special operators such as-
• comma operator
• sizeof operator
• pointer operators comma
operator
sizeof
operator
pointer
operators
COMMA OPERATOR:
• 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.
Example:
value=(x=10,y=5,x+y);
SIZE OF OPERATOR:
Sizeof is an operator used to return the number of bytes the operand occupies.
Syntax:
m=sizeof(sum);
K=sizeof(2351);
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-else
If If-else If-else if Nested if
Switch
IF STATEMENT:
• The expression must be evaluating to true or false.
• The “Statement” can be a group or in braces.
• Syntax:
If (expression)
{
statement 1;
statement 2;
}
EXAMPLE:
main()
{
int n;
printf(“Enter any number:”);
scanf(“%d”,&n);
if(n>25)
{
printf(“You can marry now”);
}
}
Enter any number:
26
You can marry now
Output:
IF-ELSE STATEMENT:
• An extension version of if statement.
• Generally in the form of if (test expression)
• Syntax:
If (test expression)
{
true block statement
}
else
{
false block statement
}
EXAMPLE:
main()
{
int num1,num2;
printf("Enter any two number: n");
scanf("%d%d",&num1,&num2);
if(num1==num2)
{
printf("They are equal");
}
else
{
printf("They are not equal");
}
}
Enter any two number:
10 11
They are not equal
Output
IF-ELSE IF:
• It is used to give series of decision.
• Syntax:
If (condition)
{
Statement 1;
}
Else if (condition 2)
{
Statement 2;
}
Else
{
Statement when all condition are false.
}
EXAMPLE:
main()
{
int num;
printf("Enter integer numn");
scanf("%d",&num);
if(num>0)
{
printf("positive");
}
else if(num<0)
{
printf("Negative");
}
else if(num==0)
{
printf("Zero");
}
}
Enter integer number
1000000
positive
Output:
NESTED IF-ELSE STATEMENT:
• New block or if else statement defined in exiting if or else block statement.
• Syntax:
If(condition1)
{
if(condition2)
{
statement1;
}
else
{
Statement2;
}
}
else
{
Statement3;
}
SWITCH 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.
• Syntax:
switch(<selector expression>)
{
Case<value1>: <sequence of statements>;
break;
Case<value2>: <sequence of the
statements>;
break;
Case<value3>: <sequence of statements>;
break;
Default: <sequence of statements>;
EXAMPLE:
main()
{
int num;
printf("Enter any number :n");
scanf("%d",&num);
switch(num % 2)
{
case 0:
printf("This number is even number");
break;
case 1:
printf("This number is odd number");
break;
}
}
Enter any number:
10
This number is even number
Output:
LOOPS:
Loops are used in programming to repeat a specific block until some end
condition is met.
 There are three loops in c programming.
 for loop
 while loop
 do while loop
FOR LOOP:
• The syntax of a for loop is:
for(initialization ; condition; variable update)
{
//code to execute while the condition is true
statement;
}
EXAMPLE:
main()
{
int i;
for(i=1;i<=50;i++)
printf("%dn",i);
}
1234567891011121314151617181920
2122232425262728293031323334353
63738394041424344454647484950
Output:
WHILE LOOP:
• The syntax of a while loop is:
while(condition)
{
//body of the loop
statement;
variable update;
}
EXAMPLE:
main()
{
int i;
i=1;
while(i<=5)
{
printf(“NDUBn");
i++;
}
}
NDUB
NDUB
NDUB
NDUB
NDUB
Output:
DO WHILE LOOP:
• The syntax of a do while loop is:
do
{
//body of the loop
Statement;
variable update;
}
While (condition);
EXAMPLE:
main()
{
int i,s=0;
i=1;
do
{
if(i%2!=0)
s=s+i;
i++;
}
while(i<=10);
printf("Summation of ODD numbers: %dn",s);
}
Summation of ODD numbers: 25
Output:
BREAK STATEMENT:
• The break statement terminates the loop immediately when it is
encountered.
• The break is used with decision making statement such as if else
• Syntax of the break statement:
break;
EXAMPLE:
int main()
{
int num;
for (num =100; num>=10; num --)
{
printf(“num: %dn", num);
if (num==99)
{
break;
}
}
printf("Out of for-loop");
}
num: 100
num: 99
Out of for-loop
Output:
CONTINUE STATEMENT:
• The continue statement skips some statements inside loop.
• The continue statement is used with decision making statement such as if
else.
• Syntax of continue statements:
continue;
EXAMPLE:
int main()
{
int j=0;
do
{
if (j==7)
{
j++;
continue;
}
printf("%d ", j);
j++;
}
while(j<10);
}
0 1 2 3 4 5 6 8 9
Output:
THE END

More Related Content

Similar to CSE 1201: Structured Programming Language

Similar to CSE 1201: Structured Programming Language (20)

CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
 
C language ppt
C language pptC language ppt
C language ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Funa-C.ppt
Funa-C.pptFuna-C.ppt
Funa-C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
C programming basic pdf.ppt
C programming basic pdf.pptC programming basic pdf.ppt
C programming basic pdf.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C--C Basics------------------.ppt
Basics of C--C Basics------------------.pptBasics of C--C Basics------------------.ppt
Basics of C--C Basics------------------.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).ppt
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

CSE 1201: Structured Programming Language

  • 1. Course Title: Structured Programming Language Course Code: CSE 1201 Batch: CSE-14 Trimester: Fall-2020 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
  • 2. 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 Data Type Variable, Constants, Identifier, Rules TOPICS:
  • 3. 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 RULES • USED TO CREATE PROGRAMS THAT CONTROL THE BEHAVIOR OF A MACHINE
  • 4. TYPES OF LANGUAGES: Programming language Low level language High level language Machine Language Assembly Language C,C++, Fortran, Java, Python, Basic, Pascal….
  • 5. Machine language:  The native language of the computer  0 and 1 these two binary digits are used to write this language Assembly 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
  • 6. Applications of Programming Language: • To create software • Software can be made for calculator or to do mathematical problems • To create web applications • In software development • Games and animations with 3d effects • For game design
  • 7. 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
  • 8. 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
  • 9. FLOW CHART: • 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.
  • 10. BASIC FLOW CHART SYMBOLS, NAME & FUNCTION:
  • 11. CONTROL STRUCTURE OF FLOW CHART:
  • 13. IMPORTANCE OF FLOW CHART: A Flowchart - • shows logic of an algorithm • emphasizes individual steps and their interconnections • Helps to control flow from one action to the next
  • 15. PSEUDO CODE: • Consists of short, readable and formally-styled English language used for explaining an algorithm. • 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
  • 16. ALGORITHM: • 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 execution.
  • 17. Example of Algorithm with Flow Chart:
  • 18. VARIABLES: • 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.
  • 19. RULES OF VARIABLES: • A variable name can only have letters (both uppercase and lowercase letters), digits, dollar sign($) and underscore. • 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 declared.**
  • 20. CONSTANTS: • 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.
  • 21. 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.
  • 22. IDENTIFIER: • 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.
  • 23. RULES OF IDENTIFIERS: • A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores. • 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.**
  • 24. EXAMPLE OF VARIABLE, CONSTANT & IDENTIFIER: If we use variable_1[5] 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.
  • 25. DATA TYPES: • 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: int myVar; 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.
  • 27. RANGE AND SIZE OF DIFFERENT DATA TYPES:
  • 28. EXAMPLE OF DATA TYPE: Input: Output:
  • 30. OPERATOR:  An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations.  These operators are used in programs to manipulate data and variables.
  • 31. TYPES OF OPERATOR: • Arithmetic operators • Relation operators • Logical operators • Assignment operators • Increment and decrement operators • Conditional operators • Bitwise operators • Special operators
  • 32. ARITHMETIC OPERATORS:  Arithmetic operator are used to perform numeric calculations among the values. Operators Meaning + Addition or unary plus - Subtraction or unary minus * Multiplication / Division % Modulo division
  • 33. EXAMPLE: main() { int a,b,add,sub,mul,div,mod; printf(“Enter two integer value:”); scanf(“%d%d”,&a,&b); add=a+b; sub=a-b; mul=a*b; div=a/b; mod=a%b; Printf(“Summation=%d”,add); Printf(“subtract=%d”,sub); Printf(“Multiplication=%d”,mul); Printf(“Division=%d”,div); Printf(“Module=%d”,mod); } Enter two integer value:20 10 Summation=30 subtract=10 Multiplication=200 Division=2 Module=0 Output:
  • 34. RELATION OPERATOR:  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. Operator Meaning < is less than <= is less than or equal > is greater then >= is greater then or equal == is equal to != is not equal to
  • 35. EXAMPLE: main() { int x=12,y=14,z=12; printf("The number of X,Y,Zn"); //is x greater than y printf("x>y=%dn",x>y); //is z less than y printf("x<y=%dn",x<y); //is y greater than or equal z printf("y>=z=%dn",y>z); //is x equal y printf("x==y=%dn",x==y); //is y not equal to z printf("y!=z=%d",y!=z); } The number of X,Y,Z x>y=0 x<y=1 y>=z=1 x==y=0 y!=z=1 Output:
  • 36. LOGICAL OPERATOR:  Logical operator are used for testing more than one condition and making decisions. Operator Meaning && Logical AND || Logical OR ! Logical NOT
  • 37. EXAMPLE: main() { int x=12,y=15,z=13,sum; printf("Enter the numbers of X,Y,Zn"); //logical And sum=(x!=z) && (x>y); printf("(x!=z) && (x>y) is %dn",sum); //logical Or sum=(x>=y) || (y<z); printf("(x>=y) || (y<z) is %dn",sum); //Logical Not sum=(x!=y); 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 Output:
  • 38. ASSIGNMENT OPERATOR: • These operator are used for assigning the result of an expression to a variable. • b=a Statement of simple assignment operator Statement with shorthand operator a =a+1 a + = 1 a=a-1 a-=1 a=a*(n+1) a*=(n+1) a=a/(n+1) a/=(n+1) a=a%b a%=b
  • 39. EXAMPLE: main() { int a,b,c; printf(“Enter three integer number:n”); scanf(“%d%d%d”,&a,&b,&c); printf(“value=%dn”,c+=b); printf(“value=%dn”,c-=b); printf(“value=%dn”,c*=b); printf(“value=%dn”,c/=b); printf(“value=%dn”,c%=b); } Output: Enter three integer number: 5 10 15 value=25 value=15 value=150 value=15 value=5
  • 40. 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.
  • 41.
  • 42. EXAMPLE: main() { int a,b,c; printf(“Enter three integer number:n”); scanf(“%d%d%d”,&a,&b,&c); printf(“value=%dn”,c=++a); printf(“value=%dn”,c=a++); printf(“value=%dn”,c=--a); printf(“value=%dn”,c=a--); } Output: Enter three integer number: 4 5 6 value=5 value=5 value=5 value=5
  • 43. CONDITIONAL OPERATORS: Syntax: exp1?exp2:exp3 Where exp1,exp2,exp3 are expressions. Operator: ?: (ternary operator)  These conditional operator are used to construct conditional expressions of the form.
  • 44. EXAMPLE: main() { int num1,num2,result; printf("Enter two numbers : n"); scanf("%d%d",&num1,&num2); result=(num1>num2) ? num1 : num2; printf("The maximum number between %d and %d is %dn",num1,num2,result); } Enter two numbers : 10 20 The maximum number between 10 and 20 is 20 Output:
  • 45. BITWISE OPERATORS: • These operator works on bit level • Applied to integer only. operator Meaning & Bitwise AND | Bitwise OR ^ Bitwise exclusive OR << Shift left >> Shift right
  • 46. SPECIAL OPERATORS: C supports some special operators such as- • comma operator • sizeof operator • pointer operators comma operator sizeof operator pointer operators
  • 47. COMMA OPERATOR: • 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. Example: value=(x=10,y=5,x+y);
  • 48. SIZE OF OPERATOR: Sizeof is an operator used to return the number of bytes the operand occupies. Syntax: m=sizeof(sum); K=sizeof(2351);
  • 49. 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
  • 50. TYPES OF DECISION-MAKING STATEMENT: If-else If If-else If-else if Nested if Switch
  • 51. IF STATEMENT: • The expression must be evaluating to true or false. • The “Statement” can be a group or in braces. • Syntax: If (expression) { statement 1; statement 2; }
  • 52. EXAMPLE: main() { int n; printf(“Enter any number:”); scanf(“%d”,&n); if(n>25) { printf(“You can marry now”); } } Enter any number: 26 You can marry now Output:
  • 53. IF-ELSE STATEMENT: • An extension version of if statement. • Generally in the form of if (test expression) • Syntax: If (test expression) { true block statement } else { false block statement }
  • 54. EXAMPLE: main() { int num1,num2; printf("Enter any two number: n"); scanf("%d%d",&num1,&num2); if(num1==num2) { printf("They are equal"); } else { printf("They are not equal"); } } Enter any two number: 10 11 They are not equal Output
  • 55. IF-ELSE IF: • It is used to give series of decision. • Syntax: If (condition) { Statement 1; } Else if (condition 2) { Statement 2; } Else { Statement when all condition are false. }
  • 56. EXAMPLE: main() { int num; printf("Enter integer numn"); scanf("%d",&num); if(num>0) { printf("positive"); } else if(num<0) { printf("Negative"); } else if(num==0) { printf("Zero"); } } Enter integer number 1000000 positive Output:
  • 57. NESTED IF-ELSE STATEMENT: • New block or if else statement defined in exiting if or else block statement. • Syntax: If(condition1) { if(condition2) { statement1; } else { Statement2; } } else { Statement3; }
  • 58. SWITCH 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. • Syntax: switch(<selector expression>) { Case<value1>: <sequence of statements>; break; Case<value2>: <sequence of the statements>; break; Case<value3>: <sequence of statements>; break; Default: <sequence of statements>;
  • 59. EXAMPLE: main() { int num; printf("Enter any number :n"); scanf("%d",&num); switch(num % 2) { case 0: printf("This number is even number"); break; case 1: printf("This number is odd number"); break; } } Enter any number: 10 This number is even number Output:
  • 60. LOOPS: Loops are used in programming to repeat a specific block until some end condition is met.  There are three loops in c programming.  for loop  while loop  do while loop
  • 61. FOR LOOP: • The syntax of a for loop is: for(initialization ; condition; variable update) { //code to execute while the condition is true statement; }
  • 63. WHILE LOOP: • The syntax of a while loop is: while(condition) { //body of the loop statement; variable update; }
  • 65. DO WHILE LOOP: • The syntax of a do while loop is: do { //body of the loop Statement; variable update; } While (condition);
  • 67. BREAK STATEMENT: • The break statement terminates the loop immediately when it is encountered. • The break is used with decision making statement such as if else • Syntax of the break statement: break;
  • 68. EXAMPLE: int main() { int num; for (num =100; num>=10; num --) { printf(“num: %dn", num); if (num==99) { break; } } printf("Out of for-loop"); } num: 100 num: 99 Out of for-loop Output:
  • 69. CONTINUE STATEMENT: • The continue statement skips some statements inside loop. • The continue statement is used with decision making statement such as if else. • Syntax of continue statements: continue;
  • 70. EXAMPLE: int main() { int j=0; do { if (j==7) { j++; continue; } printf("%d ", j); j++; } while(j<10); } 0 1 2 3 4 5 6 8 9 Output: