SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
Harish Kumawat
 
class and objects
class and objectsclass and objects
class and objects
Payel Guria
 
Language processor
Language processorLanguage processor
Language processor
Abha Damani
 

La actualidad más candente (20)

Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Functions in C
Functions in CFunctions in C
Functions in C
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
class and objects
class and objectsclass and objects
class and objects
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Language processor
Language processorLanguage processor
Language processor
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 

Similar a structured 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
ManiMala75
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
miki304759
 
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
sarthakgithub
 

Similar a 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 in C
User defined functions in CUser defined functions in C
User defined functions in C
 
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
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Último (20)

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
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
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
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

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); }