SlideShare a Scribd company logo
1 of 18
Programming Fundamentals
Group
Structured Programming
What is Structured Programming?
In structured programming,we divide
the whole program into small
modules, so that program become
easy to understand.
Why we use Structured Programming?
• We use structured programming because it
enables the programmer to understand the
program easily.
• If a program consists of thousands of instructions
and an error occurs than it is very difficult to find
that error in the whole program but in structured
programming we can easily detect the error and
then go to that location and correct it.
• This saves a lot of time.
Structured Programming Concepts
• Top Down Design.
• Code reusability.
• Information hiding.
Function
• We divide the whole program in to small
blocks called functions.
• Function is a block of statements that are
executed to perform a task.
• Function plays an important role in structured
programming.
• Using a function is like hiring a person to do a
specific job.
Function Call :
• When a function is called by its name the control
moves to the function definition and executes all
the statements written in it
• Semi colon is used after the name of function.
Function Definition :
• Function definition contains the instructions that
are executed when a function is called
• Semi colon is not used after the name of function.
Function call and definition
main()
{
message();
printf(“Hello world n”);
}
message()
{
printf(“Message function n”);
}
Waiting
Function
call
Function
definition
Points to remember
• C program must contains at least one function
• Execution of C program begins with main() function.
• If there are more than one function then one function
must be main()
• There is no limit on number of functions in C program
• Functions in a program are called in sequence as
mentioned in main() function
• After the execution of function control returns to
main()
• A function can call itself such a process is called
recursion.
main()
{
printf("During Summer ");
wakeup();
milk();
Study();
Play();
Sleep();
system("pause");
}
study()
{
printf("I study at 2’pm");
}
wakeup()
{
printf("I wake up at 6'am");
}
milk()
{
printf("I drink milk at 8'am");
}
Sleep()
{
printf("I sleep at 9'pm");
}
Play()
{
printf("I play at 3'pm");
}
Function Call Function Definition
Function Prototype
Function prototype contains following things about
the function:
• The data type returned by the function
• The number of parameters received
• The data types of the parameters
• The order of the parameters
• If there is no datatype and return value then we
use void at the place of datatype and perameters
int m(int,int);
main()
{
int a,b,Mul;
printf("Enter the values of a and b");
scanf("%d%d",&a,&b);
Mul=m(a,b);
printf("Multiplication of a & b is %d",Mul);
system("pause");
}
m(int x,int y)
{
int mul;
mul=x*y;
return(mul);
}
Function prototype
Function Call
Function Definition
Imp Point
• A function can return only one value at a time
for example these statements are invalid:
Return(a,b);
Return(x,12);
Return value Program
int m(int,int);
main()
{
int a,b,Mul;
printf("Enter the values of a and b");
scanf("%d%d",&a,&b);
Mul=m(a,b);
printf("Multiplication of a & b is %d",Mul);
system("pause");
}
m(int x,int y)
{
int mul;
mul=x*y;
return(mul);
}
• If the value of a formal argument is changed in the
called function, the corresponding change does not
take place in the calling function. For example
30a
60b
Variable Scope
• Variable scope determine the area in a program where
variable can be accessed.
• When a variable loses its scope, it means its data value
is lost
• Common types of variables in C,
– local
– global
• Global variable can be accessed any where in a
program
• Local variable can be accessed only in that function in
which it is declared
Example Program
#include<stdio.h>
int a,b; Global Variable
main()
{
printf("Enter the values of a & b");
scanf("%d%d",&a,&b);
sum(a,b);
system("pause");
}
sum(inta,intb)
{
int c; Local Variable
c=a+b;
printf("Sum is %d",c);
}
structured programming
structured programming

More Related Content

What's hot (20)

C if else
C if elseC if else
C if else
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Modular programming
Modular programmingModular programming
Modular programming
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
String functions in C
String functions in CString functions in C
String functions in C
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 

Similar to structured programming

Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C ProgrammingAnil Pokhrel
 
662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf
662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf
662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdfManiMala75
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdflailoesakhan
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxKhurramKhan173
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxsarthakgithub
 
Rdbms chapter 1 function
Rdbms chapter 1 functionRdbms chapter 1 function
Rdbms chapter 1 functiondipumaliy
 
ch-3 funtions - 1 class 12.pdf
ch-3 funtions - 1 class 12.pdfch-3 funtions - 1 class 12.pdf
ch-3 funtions - 1 class 12.pdfzafar578075
 
predefined and user defined functions
predefined and user defined functionspredefined and user defined functions
predefined and user defined functionsSwapnil Yadav
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2sumitbardhan
 

Similar to structured programming (20)

Basic c++
Basic c++Basic c++
Basic c++
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf
662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf
662213141-Tuxdoc-com-Programming-in-c-Reema-Thareja.pdf
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
CPP06 - Functions
CPP06 - FunctionsCPP06 - Functions
CPP06 - Functions
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptx
 
Function
Function Function
Function
 
Functions
FunctionsFunctions
Functions
 
Rdbms chapter 1 function
Rdbms chapter 1 functionRdbms chapter 1 function
Rdbms chapter 1 function
 
Function in c program
Function in c programFunction in c program
Function in c program
 
User defined functions.1
User defined functions.1User defined functions.1
User defined functions.1
 
ch-3 funtions - 1 class 12.pdf
ch-3 funtions - 1 class 12.pdfch-3 funtions - 1 class 12.pdf
ch-3 funtions - 1 class 12.pdf
 
predefined and user defined functions
predefined and user defined functionspredefined and user defined functions
predefined and user defined functions
 
UNIT 3 python.pptx
UNIT 3 python.pptxUNIT 3 python.pptx
UNIT 3 python.pptx
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
Functions
FunctionsFunctions
Functions
 
Functions
FunctionsFunctions
Functions
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Recently uploaded (20)

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

structured programming

  • 2. Structured Programming What is Structured Programming? In structured programming,we divide the whole program into small modules, so that program become easy to understand.
  • 3. Why we use Structured Programming? • We use structured programming because it enables the programmer to understand the program easily. • If a program consists of thousands of instructions and an error occurs than it is very difficult to find that error in the whole program but in structured programming we can easily detect the error and then go to that location and correct it. • This saves a lot of time.
  • 4. Structured Programming Concepts • Top Down Design. • Code reusability. • Information hiding.
  • 5. Function • We divide the whole program in to small blocks called functions. • Function is a block of statements that are executed to perform a task. • Function plays an important role in structured programming. • Using a function is like hiring a person to do a specific job.
  • 6. Function Call : • When a function is called by its name the control moves to the function definition and executes all the statements written in it • Semi colon is used after the name of function. Function Definition : • Function definition contains the instructions that are executed when a function is called • Semi colon is not used after the name of function.
  • 7. Function call and definition main() { message(); printf(“Hello world n”); } message() { printf(“Message function n”); } Waiting Function call Function definition
  • 8. Points to remember • C program must contains at least one function • Execution of C program begins with main() function. • If there are more than one function then one function must be main() • There is no limit on number of functions in C program • Functions in a program are called in sequence as mentioned in main() function • After the execution of function control returns to main() • A function can call itself such a process is called recursion.
  • 9. main() { printf("During Summer "); wakeup(); milk(); Study(); Play(); Sleep(); system("pause"); } study() { printf("I study at 2’pm"); } wakeup() { printf("I wake up at 6'am"); } milk() { printf("I drink milk at 8'am"); } Sleep() { printf("I sleep at 9'pm"); } Play() { printf("I play at 3'pm"); } Function Call Function Definition
  • 10. Function Prototype Function prototype contains following things about the function: • The data type returned by the function • The number of parameters received • The data types of the parameters • The order of the parameters • If there is no datatype and return value then we use void at the place of datatype and perameters
  • 11. int m(int,int); main() { int a,b,Mul; printf("Enter the values of a and b"); scanf("%d%d",&a,&b); Mul=m(a,b); printf("Multiplication of a & b is %d",Mul); system("pause"); } m(int x,int y) { int mul; mul=x*y; return(mul); } Function prototype Function Call Function Definition
  • 12. Imp Point • A function can return only one value at a time for example these statements are invalid: Return(a,b); Return(x,12);
  • 13. Return value Program int m(int,int); main() { int a,b,Mul; printf("Enter the values of a and b"); scanf("%d%d",&a,&b); Mul=m(a,b); printf("Multiplication of a & b is %d",Mul); system("pause"); } m(int x,int y) { int mul; mul=x*y; return(mul); }
  • 14. • If the value of a formal argument is changed in the called function, the corresponding change does not take place in the calling function. For example 30a 60b
  • 15. Variable Scope • Variable scope determine the area in a program where variable can be accessed. • When a variable loses its scope, it means its data value is lost • Common types of variables in C, – local – global • Global variable can be accessed any where in a program • Local variable can be accessed only in that function in which it is declared
  • 16. Example Program #include<stdio.h> int a,b; Global Variable main() { printf("Enter the values of a & b"); scanf("%d%d",&a,&b); sum(a,b); system("pause"); } sum(inta,intb) { int c; Local Variable c=a+b; printf("Sum is %d",c); }