PCCF UNIT 1.pptx

D
COMPUTING AND PROGRAMMING
FUNDAMENTAL
Programming Process
Developing a Program, Program Development Cycle;
Introduction to Algorithms,Characteristics, Writing an
Algorithm; Flowchart, Symbols, Guidelines for Preparing
Flowchart, Benefits of Flowcharts, Limitations of
Flowcharts; Pseudocode, Pseudocode guidelines,
Benefits of pseudocode, Limitations of Pseudocode;
Program Control Structures.
1
PROGRAM – COLLECTION OF INSTRUCTIONS
 A program is a set of instructions that a computer follows in order to
perform a particular task.
 A computer program, or just a program, is a sequence of instructions,
written to perform a specified task on a computer.
 A computer requires programs to function, typically executing the
program's instructions in a central processor.
2
3
4
5
DEVELOPING A PROGRAM
 Plan
 Code
Programmer:
 Good programmer – First plan then code
 Large programming task – divide sub process
 30 minutes planning could save hours of trying to make the code work
properly.
 Well planned code is not only more likely to be correct (or at least closer
to correct), but is also easier to understand—and thus fix. 6
ADD TWO NUMBER
 Plan –
 Declare two numbers
 Give values to these two number
 Store the output of these two added number, so need third
variable – have to declare 3 variable.
 Logically think – c=a+b;
 Display the c value.
Code
int a=10,b=20,c;
c=a+b;
print the c value: = 30
Output: 30 7
PROGRAMMING
 Computer programming (often shortened to programming) is a process that leads from
an original formulation of a computing problem to executable computer programs
 Programming involves activities such as analysis, developing understanding,
generating algorithms, verification of requirements of algorithms including their
correctness and resources consumption, and implementation (commonly referred to as
coding) of algorithms in a target programming language.
 Source code is written in one or more programming languages.
 The purpose of programming is to find a sequence of instructions that will automate
performing a specific task or solving a given problem.
 The process of programming thus often requires expertise in many different subjects,
including knowledge of the application domain, specialized algorithms and formal
logic.
8
PDLC
 1. Analyze the problem
 Precisely define the problem to be solved, and write program
specifications – descriptions of the program’s inputs, processing,
outputs, and user interface.
 Eg :
Problem : To find the sum of natural numbers
Inputs : 2 positive numbers
Processing : Adding first number and second number and
storing/Print the result
 User Interface : Any Programming Language (C compiler) 9
PDLC
 2. Design the program
 Develop a detailed logic plan using a tool such as pseudo code, flowcharts,
object structure diagrams, or event diagrams to group the program’s
activities into modules;
 Devise a method of solution or algorithm for each module; and test the
solution algorithms.

10
PDLC
 3. Code the program
 Translate the design into an application using a programming language or
application development tool by creating the user interface and writing code;
include internal documentation
 – comments and remarks within the code that explain the purpose of code
statements.
11
#include<stdio.h>
main()
{
int A, B, TOTAL; // Declare the input variables
printf(“ Enter the first number”);
scanf(%d”, &A); // Get the first input from the user
printf(“ Enter the Second number”);
scanf(%d”, &B); // Get the second input from the user
TOTAL=A+B; // Add the numbers and store it in a variable
printf(“ The Sum of Two numbers is %d”,TOTAL); // Print the output
getch() ; }
12
PDLC
 4. Test and debug the program
 Test the program, finding and correcting errors (debugging) until it is error free and
contains enough safeguards to ensure the desired results.
 5. Formalize the solution
 Review and, if necessary, revise internal documentation; formalize and complete end-
user (external) documentation
 6. Operate and Maintain the program
 Provide education and support to end users; correct any unanticipated errors that
emerge and identify user-requested modifications (enhancements). Once errors or
enhancements are identified, the program development life cycle begins again at Step
1.
13
ALGORITHM
 An algorithm is a set of instructions for solving a problem or
accomplishing a task. (or)
 An algorithm is an effective method and self-contained step-
by-step set of operations to be perform a task in finite amount
of time and space.
Level of description:
 High-level description -algorithm, ignoring the
implementation details.
 Implementation description- way the implementation is done
 Formal description- a finite sequence of instructions to solve
some problem
14
CHARACTERISTICS
 Instruction precise and unambiguous
 Finite time
 Not be repeated indefinitely
 Optimal results – according to input
 Unique solution
 Finite number of steps
 Meaningful information
 Easy for understanding – begginer
15
ALGORITHM WRITING
1. Get a clear understanding of the problem statement.
2. Proceed in a step by step fashion.
3. Divide the job into parts.
4. Include variables and their usage and define expressions.
5. Outline each loop
6. Include action statements.
7. Work outwards from the Action Statements, figuring out how each parameter will be determined
each time the loop goes around
8. Go back to step number if loop or condition fails.
9. Use jump statement to jump from one statement to another.
10. Try to avoid unwanted raw data in algorithm.
11. Use break and stop to terminate the process. 16
EXAMPLE:
 Algorithm to find area of a circle
1. Start
2. Input the value of radius R
3. Let PI=3.14
4. Calculate area=PI*R*R
5. Print area
6.End 17
FLOWCHART
How to describe an animal to baby?
color,size, etc – not understand
Show picture –
Now – baby understood
“ PICTURES TALKS MORE THAN WORDS’
Like flowcharts - graphical representation of computer
programs. 18
FLOWCHARTS CONT’
 A flowchart is a visual representation of the sequence of
steps and decisions needed to perform a process.
 Flowcharts use special shapes to represent different types
of actions or steps in a process.
Types :
I. Sequential Structure – sequential order
II. Selective Structure – condition expression (T/F)
III. Looping Structure – Iteration – repeatedly check condition
until false
19
SEQUENCIAL
20
SELECTIVE
21
LOOPING
22
SYMBOLS
23
SYMBOLS
24
25
On-page Connector
Connects two or more parts of
a flowchart, which are on the
same page.
Off-page Connector
Connects two parts of a
flowchart which are spread
over different pages.
26
GUIDELINES
 Understand a system before flowcharting it.
 Flowchart can have only one start and one stop symbol
 Identify the entities, such as departments, job functions, or external
parties that are to be flowcharted.
 divide the flowchart into columns, label each column
 Use standard flowcharting symbols
 Clearly label all symbols
 Use arrowheads on all flow lines.
 Try to use only one page per flowchart
 On-page connectors are referenced using numbers
 Off-page connectors are referenced using alphabets
 General flow of processes is top to bottom or left to right
 Arrows should not cross each other
 Place the name of the flowchart, the date it was prepared, and the
designer's name on each page of the flowchart. 27
HOW TO DRAW FLOWCHART
 Input is Number1, Number2
 Output is stored in Sum
 Concentrate on the symbols used.
28
FLOWCHART ADVANTAGES
 Flowcharts are easier to understand compare to
Algorithms and Pseudo code.
 It helps us to understand Logic of given problem.
 It is very easy to draw flowchart in any word
processing software like MS Word.
 Using only very few symbol, complex problem can be
represented in flowchart.
 Software like RAPTOR can be used to check
correctness of flowchart drawn in computers.
 Flowcharts are one of the good way of documenting
programs.
 It helps us in debugging process.
29
FLOWCHART DISADVANTAGES
 Manual tracing is needed to check correctness of
flowchart drawn on paper.
 Simple modification in problem logic may leads to
complete redraw of flowchart.
 Showing many branches and looping in flowchart is
difficult.
 In case of complex program/algorithm, flowchart
becomes very complex and clumsy.
 Modification of flowchart is sometimes time consuming.
30
PSEUDO CODE
 A notation resembling a simplified programming language, used in program
design.
 An outline of a program, written in a form that can easily be converted into real
programming statements.
 Pseudocode cannot be compiled nor executed, and there are no real formatting
or syntax rules. It is simply one step - an important one - in producing the final
code
 Pseudocode is a "text-based" detail (algorithmic) design tool.
 Include control structures such as WHILE, IF-THEN-ELSE, REPEAT-UNTIL,
FOR, and CASE, which are present in many high level languages 31
PSEUDO GUIDELINES : RULES FOR PSEUDOCODE
 Write only one statement per line
 Capitalize initial keyword
 Indent to show hierarchy
 End multiline structures
 Keep statements language independent
32
GUIDELINES CONT’
 1. Write only one statement per line:
 READ a,b
 2. Capitalize initial keyword
 READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE,
REPEAT, UNTIL 3
3. Indent to show hierarchy
SEQUENCE - all starting in the same column.
SELECTION - indent the statements that fall inside the
selection structure, but not the keywords that form the
selection
LOOPING- indent the statements that fall inside the loop, but
not the keywords that form the loop
33
GUIDELINES CONT’
 4. End multiline structures
 how the IF/ELSE/ENDIF is constructed above. The ENDIF
(or END whatever) always is in line with the IF (or whatever
starts the structure).
 5. Keep statements language independent
 to write in whatever language you are most comfortable
with.
 if you are SURE it will be written in that language, then you
can use the features. If not, then avoid using the special
features.
34
BENEFITS/ADVANTAGES OF PSEUDOCODE:
 Can be done easily on a word processor Easily modified
 Implements structured concepts well
 Clarify algorithms in many cases.
 Impose increased discipline on the process of documenting detailed design. Provide additional level at which
inspection can be performed.
 Help to trap defects before they become code.
 Increases product reliability.
 May decreases overall costs.
 It can be easily modified as compared to flowchart.
 Its implementation is very useful in structured design elements.
 It can be written easily.
 It can be read and understood easily.
 Converting a pseudocode to programming language is very easy as compared with converting a flowchart to
programming language.
35
LIMITATIONS/DISADVANTAGES OF PSEUDO
CODE:
 It's not visual
 Create an additional level of documentation to maintain.
 Introduce error possibilities in translating to code.
 May require tool to extract pseudocode and facilitate drawing flowcharts.
 There is no accepted standard, so it varies widely from company to company
 We do not get a picture of the design.
 There is no standardized style or format, so one pseudocode may be different from
another.
 For a beginner, it is more difficult to follow the logic or write pseudocode as compared to
flowchart.
36
EXAMPLE FOR PSEUDO CODE
BEGIN
READ A,B
IF(A>B)
PRINT A
ELSE
PRINT B
ENDIF
END
37
PROGRAM CONTROL STRUCTURE
 Control Structures are just a way to specify flow of
control in programs.
 Analyze the flow control
 Act as a decision maker in computing
Basic Terminology:
1) Precondition (Entry control) - state of variables
before entering a control structure.
2) Post condition (Exit control)- state of variables after
the algorithm is run
38
BASIC CONTROL STRUCTURE
 Sequential
 Selection / conditional / Decision control statements
 Looping /Iteration/ Repetition
39
SEQUENCE
40
SELECTION
41
LOOPING
 for(Expression 1; Expression 2; Expression 3){
 //code to be executed
 }
42
#include<stdio.h>
int main(){
int i=0;
for(i=1;i<=10;i++){
printf("%d n",i);
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
43
DECISION MAKING
 if statement
 if..else statements
 nested if statements
 if-else-if ladder
 switch statements
 Jump Statements:
 break
 continue
 goto
 return 44
IF
 int main() {
 int i = 10;

 if (i > 15)
 {
 printf("10 is less than 15");
 }

 printf("I am Not in if");
 }
45
IF ELSE
 int main() {
 int i = 20;

 if (i < 15){

 printf("i is smaller than 15");
 }
 else{

 printf("i is greater than 15");
 }
 return 0;
 }
46
// C program to illustrate nested-if statement
#include <stdio.h>
int main() {
int i = 10;
if (i == 10)
{
// First if statement
if (i < 15)
printf("i is smaller than 15n");
// Nested - if statement
// Will only be executed if statement above
// is true
if (i < 12)
printf("i is smaller than 12 toon");
else
printf("i is greater than 15");
}
return 0;
47
NESTED-IF ELSE STATEMENT
#include <stdio.h>
int main() {
int i = 20;
if (i == 10)
printf("i is 10");
else if (i == 15)
printf("i is 15");
else if (i == 20)
printf("i is 20");
else
printf("i is not present");
} 48
BREAK
 #include<stdio.h>
 #include<stdlib.h>
 void main ()
 {
 int i;
 for(i = 0; i<10; i++)
 {
 printf("%d ",i);
 if(i == 5)
 break;
 }
 printf("came outside of loop i = %d",i);

 }
 o/p :0 1 2 3 4 5 came outside of loop i = 5
49
CONTINUE
50
 //loop statements
 continue;
 //some lines of the code which is to be skipped
 #include<stdio.h>
 void main ()
 {
 int i = 0;
 while(i!=10)
 {
 printf("%d", i);
 continue;
 i++;
 }
 }
 Output :infinite loop
 Syntax1 | Syntax2
 ----------------------------
 goto label; | label:
 . | .
 . | .
 . | .
 label: | goto label;
51
GOTO
// C program to print numbers
// from 1 to 10 using goto statement
#include <stdio.h>
// function to print numbers from 1 to 10
void printNumbers()
{
int n = 1;
label:
printf("%d ",n);
n++;
if (n <= 10)
goto label;
}
// Driver program to test above function
int main() {
printNumbers();
return 0;
}
52
 #include <stdio.h>
 int main()
 {
 int num,i=1;
 printf("Enter the number whose t
able you want to print?");
 scanf("%d",&num);
 table:
 printf("%d x %d = %dn",num,i,nu
m*i);
 i++;
 if(i<=10)
 goto table;
 }
 Enter the
number
whose
table you
want to
print?10 10
x 1 = 10 10
x 2 = 20 10
x 3 = 30 10
x 4 = 40 10
x 5 = 50 10
x 6 = 60 10
x 7 = 70 10
x 8 = 80 10
x 9 = 90 10
x 10 = 100
// C code to illustrate return
// statement
#include <stdio.h>
// non-void return type
// function to calculate sum
int SUM(int a, int b)
{
int s1 = a + b;
return s1;
}
// returns void
// function to print
void Print(int s2)
{
printf("The sum is %d", s2);
return;
}
53
int main()
{
int num1 = 10;
int num2 = 10;
int sum_of =
SUM(num1, num2);
Print(sum_of);
return 0;
}
Output: The sum is 20
SWITCH
switch(expression){
case value1:
//code to be executed;
break; //optional
case value2:
//code to be executed;
break; //optional
......
default:
code to be executed if all cases are not matched;
}
54
Rules for switch statement in C
language
1) The switch expression must be
of an integer or character type.
2) The case value must be an
integer or character constant.
55
SWITCH
 #include<stdio.h>
 int main(){
 int number=0;
 printf("enter a number:");
 scanf("%d",&number);
 switch(number){
 case 10:
 printf("number is equals to 10
");
 break;
 case 50:
 printf("number is equal to 50")
;
 break;
56
 case 100:
 printf("number is equal to 100");
 break;
 default:
 printf("number is not equal to 10,
50 or 100");
 }
 return 0;
 }
 Output :
 enter a number:4 number is not
equal to 10, 50 or 100
LOOP
57
 FOR
 NESTED FOR
 WHILE
 DO WHILE
FOR
 for(Expression 1; Expression 2; Expression 3){
 //code to be executed
 }
58
#include<stdio.h>
int main(){
int i=0;
for(i=1;i<=10;i++){
printf("%d n",i);
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
NESTEAD LOOP
#include<stdio.h>
int main(){
int i=1,j=1;//initializing a local variable
for(i=1;i<=3;i++){
for(j=1;j<=3;j++){
printf("%d &dn",i,j);
if(i==2 && j==2){
break;//will break loop of j only
}
}//end of for loop
return 0;
}
59
1 1
1 2
1 3
2 1
2 2
3 1
3 2
3 3
WHILE
 while(condition){
 //code to be execut
ed
 }
 #include<stdio.h>
 int main(){
 int i=1;
 while(i<=10){
 printf("%d n",i);
 i++;
 }
 return 0;
 }
60
Output :
1
2
-
-
10
DO WHILE
 do{
 //code to be execute
d
 }while(condition);
 #include<stdio.h>
 int main(){
 int i=1;
 do{
 printf("%d n",i);
 i++;
 }while(i<=10);
 return 0;
 } 61
 Output:
 1
 2
 -
 -
 10
1 de 61

Recomendados

lecture 5 por
 lecture 5 lecture 5
lecture 5umardanjumamaiwada
191 visualizações25 slides
Introduction to computer science por
Introduction to computer scienceIntroduction to computer science
Introduction to computer scienceumardanjumamaiwada
86 visualizações25 slides
Algorithm,Pseudocode,Flowchart.pptx por
Algorithm,Pseudocode,Flowchart.pptxAlgorithm,Pseudocode,Flowchart.pptx
Algorithm,Pseudocode,Flowchart.pptxDrThenmozhiKarunanit
55 visualizações66 slides
What is algorithm por
What is algorithmWhat is algorithm
What is algorithmmshoaib15
80 visualizações30 slides
PROBLEM SOLVING por
PROBLEM SOLVINGPROBLEM SOLVING
PROBLEM SOLVINGshahzadebaujiti
102 visualizações7 slides
Stnotes doc 5 por
Stnotes doc 5Stnotes doc 5
Stnotes doc 5Alok Jain
320 visualizações94 slides

Mais conteúdo relacionado

Similar a PCCF UNIT 1.pptx

Fundamentals of programming with C++ por
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++Seble Nigussie
245 visualizações113 slides
Introduction to problem solving in C por
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in CDiwakar Pratap Singh 'Deva'
26.9K visualizações23 slides
Chapter 5( programming) answer por
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answersmkengkilili2011
2.8K visualizações24 slides
Programming process and flowchart por
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
9.6K visualizações34 slides
PDLC.pptx por
PDLC.pptxPDLC.pptx
PDLC.pptxmarysj3
3 visualizações19 slides
Algorithm and Flowcharts por
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and FlowchartsSURBHI SAROHA
4.1K visualizações14 slides

Similar a PCCF UNIT 1.pptx(20)

Fundamentals of programming with C++ por Seble Nigussie
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
Seble Nigussie245 visualizações
Chapter 5( programming) answer por smkengkilili2011
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answer
smkengkilili20112.8K visualizações
Programming process and flowchart por hermiraguilar
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
hermiraguilar9.6K visualizações
PDLC.pptx por marysj3
PDLC.pptxPDLC.pptx
PDLC.pptx
marysj33 visualizações
Algorithm and Flowcharts por SURBHI SAROHA
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and Flowcharts
SURBHI SAROHA4.1K visualizações
Algorithms and flow charts por Chinnu Edwin
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin178 visualizações
Introduction to Computer Programming por Prof. Erwin Globio
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
Prof. Erwin Globio2K visualizações
Software development slides por iarthur
Software development slidesSoftware development slides
Software development slides
iarthur16.1K visualizações
Overview of c++ por geeeeeet
Overview of c++Overview of c++
Overview of c++
geeeeeet9.9K visualizações
SWE-401 - 9. Software Implementation por ghayour abbas
SWE-401 - 9. Software ImplementationSWE-401 - 9. Software Implementation
SWE-401 - 9. Software Implementation
ghayour abbas50 visualizações
9. Software Implementation por ghayour abbas
9. Software Implementation9. Software Implementation
9. Software Implementation
ghayour abbas236 visualizações
UNIT 2 ECSE-2.pptx por AdharshKokkula
UNIT 2 ECSE-2.pptxUNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptx
AdharshKokkula26 visualizações
Program logic and design por Chaffey College
Program logic and designProgram logic and design
Program logic and design
Chaffey College3.4K visualizações
Problem Solving Techniques por Ashesh R
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
Ashesh R10.9K visualizações
Introduction to Programming.docx por JohnBrianCatedrilla1
Introduction to Programming.docxIntroduction to Programming.docx
Introduction to Programming.docx
JohnBrianCatedrilla124 visualizações
C programming for Computing Techniques por Appili Vamsi Krishna
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna906 visualizações
Ss debuggers por sweety enit
Ss debuggersSs debuggers
Ss debuggers
sweety enit686 visualizações
C tutorials por sujit11feb
C tutorialsC tutorials
C tutorials
sujit11feb428 visualizações

Mais de DivyaKS12

NUMBER SYSTEM.pptx por
NUMBER SYSTEM.pptxNUMBER SYSTEM.pptx
NUMBER SYSTEM.pptxDivyaKS12
8 visualizações14 slides
unit 3.pptx por
unit 3.pptxunit 3.pptx
unit 3.pptxDivyaKS12
14 visualizações68 slides
PCCF UNIT 2.pptx por
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptxDivyaKS12
24 visualizações63 slides
DBMS-INTRODUCTION.pptx por
DBMS-INTRODUCTION.pptxDBMS-INTRODUCTION.pptx
DBMS-INTRODUCTION.pptxDivyaKS12
190 visualizações86 slides
Database models and DBMS languages por
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languagesDivyaKS12
16 visualizações27 slides
Operation research (definition, phases) por
Operation research (definition, phases)Operation research (definition, phases)
Operation research (definition, phases)DivyaKS12
3.1K visualizações34 slides

Mais de DivyaKS12(13)

NUMBER SYSTEM.pptx por DivyaKS12
NUMBER SYSTEM.pptxNUMBER SYSTEM.pptx
NUMBER SYSTEM.pptx
DivyaKS128 visualizações
unit 3.pptx por DivyaKS12
unit 3.pptxunit 3.pptx
unit 3.pptx
DivyaKS1214 visualizações
PCCF UNIT 2.pptx por DivyaKS12
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptx
DivyaKS1224 visualizações
DBMS-INTRODUCTION.pptx por DivyaKS12
DBMS-INTRODUCTION.pptxDBMS-INTRODUCTION.pptx
DBMS-INTRODUCTION.pptx
DivyaKS12190 visualizações
Database models and DBMS languages por DivyaKS12
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
DivyaKS1216 visualizações
Operation research (definition, phases) por DivyaKS12
Operation research (definition, phases)Operation research (definition, phases)
Operation research (definition, phases)
DivyaKS123.1K visualizações
Types of Computer Modem por DivyaKS12
Types of Computer ModemTypes of Computer Modem
Types of Computer Modem
DivyaKS121K visualizações
UI controls in Android por DivyaKS12
UI controls in Android UI controls in Android
UI controls in Android
DivyaKS12284 visualizações
Fragments In Android por DivyaKS12
Fragments In AndroidFragments In Android
Fragments In Android
DivyaKS1279 visualizações
Android os(comparison all other mobile os) por DivyaKS12
Android os(comparison all other mobile os)Android os(comparison all other mobile os)
Android os(comparison all other mobile os)
DivyaKS12142 visualizações
Introduction to java script por DivyaKS12
Introduction to java scriptIntroduction to java script
Introduction to java script
DivyaKS1299 visualizações
CSS por DivyaKS12
CSSCSS
CSS
DivyaKS1271 visualizações
Internet technology por DivyaKS12
Internet technologyInternet technology
Internet technology
DivyaKS1237 visualizações

Último

BUSINESS ETHICS MODULE 1 UNIT I_A.pdf por
BUSINESS ETHICS MODULE 1 UNIT I_A.pdfBUSINESS ETHICS MODULE 1 UNIT I_A.pdf
BUSINESS ETHICS MODULE 1 UNIT I_A.pdfDr Vijay Vishwakarma
40 visualizações25 slides
Monthly Information Session for MV Asterix (November) por
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)Esquimalt MFRC
98 visualizações26 slides
Gross Anatomy of the Liver por
Gross Anatomy of the LiverGross Anatomy of the Liver
Gross Anatomy of the Liverobaje godwin sunday
74 visualizações12 slides
The Accursed House by Émile Gaboriau por
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile GaboriauDivyaSheta
246 visualizações15 slides
Mineral nutrition and Fertilizer use of Cashew por
 Mineral nutrition and Fertilizer use of Cashew Mineral nutrition and Fertilizer use of Cashew
Mineral nutrition and Fertilizer use of CashewAruna Srikantha Jayawardana
53 visualizações107 slides
ANGULARJS.pdf por
ANGULARJS.pdfANGULARJS.pdf
ANGULARJS.pdfArthyR3
49 visualizações10 slides

Último(20)

BUSINESS ETHICS MODULE 1 UNIT I_A.pdf por Dr Vijay Vishwakarma
BUSINESS ETHICS MODULE 1 UNIT I_A.pdfBUSINESS ETHICS MODULE 1 UNIT I_A.pdf
BUSINESS ETHICS MODULE 1 UNIT I_A.pdf
Dr Vijay Vishwakarma40 visualizações
Monthly Information Session for MV Asterix (November) por Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC98 visualizações
Gross Anatomy of the Liver por obaje godwin sunday
Gross Anatomy of the LiverGross Anatomy of the Liver
Gross Anatomy of the Liver
obaje godwin sunday74 visualizações
The Accursed House by Émile Gaboriau por DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta246 visualizações
ANGULARJS.pdf por ArthyR3
ANGULARJS.pdfANGULARJS.pdf
ANGULARJS.pdf
ArthyR349 visualizações
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf por Dr Vijay Vishwakarma
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdfSTRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf
Dr Vijay Vishwakarma90 visualizações
Retail Store Scavenger Hunt.pptx por jmurphy154
Retail Store Scavenger Hunt.pptxRetail Store Scavenger Hunt.pptx
Retail Store Scavenger Hunt.pptx
jmurphy15452 visualizações
Java Simplified: Understanding Programming Basics por Akshaj Vadakkath Joshy
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming Basics
Akshaj Vadakkath Joshy625 visualizações
Parts of Speech (1).pptx por mhkpreet001
Parts of Speech (1).pptxParts of Speech (1).pptx
Parts of Speech (1).pptx
mhkpreet00143 visualizações
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37 por MysoreMuleSoftMeetup
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37
MysoreMuleSoftMeetup44 visualizações
MIXING OF PHARMACEUTICALS.pptx por Anupkumar Sharma
MIXING OF PHARMACEUTICALS.pptxMIXING OF PHARMACEUTICALS.pptx
MIXING OF PHARMACEUTICALS.pptx
Anupkumar Sharma117 visualizações
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice por Taste
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceCreative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Taste41 visualizações
Education of marginalized and socially disadvantages segments.pptx por GarimaBhati5
Education of marginalized and socially disadvantages segments.pptxEducation of marginalized and socially disadvantages segments.pptx
Education of marginalized and socially disadvantages segments.pptx
GarimaBhati540 visualizações
Jibachha publishing Textbook.docx por DrJibachhaSahVetphys
Jibachha publishing Textbook.docxJibachha publishing Textbook.docx
Jibachha publishing Textbook.docx
DrJibachhaSahVetphys54 visualizações
INT-244 Topic 6b Confucianism por S Meyer
INT-244 Topic 6b ConfucianismINT-244 Topic 6b Confucianism
INT-244 Topic 6b Confucianism
S Meyer44 visualizações
Guess Papers ADC 1, Karachi University por Khalid Aziz
Guess Papers ADC 1, Karachi UniversityGuess Papers ADC 1, Karachi University
Guess Papers ADC 1, Karachi University
Khalid Aziz83 visualizações

PCCF UNIT 1.pptx

  • 1. COMPUTING AND PROGRAMMING FUNDAMENTAL Programming Process Developing a Program, Program Development Cycle; Introduction to Algorithms,Characteristics, Writing an Algorithm; Flowchart, Symbols, Guidelines for Preparing Flowchart, Benefits of Flowcharts, Limitations of Flowcharts; Pseudocode, Pseudocode guidelines, Benefits of pseudocode, Limitations of Pseudocode; Program Control Structures. 1
  • 2. PROGRAM – COLLECTION OF INSTRUCTIONS  A program is a set of instructions that a computer follows in order to perform a particular task.  A computer program, or just a program, is a sequence of instructions, written to perform a specified task on a computer.  A computer requires programs to function, typically executing the program's instructions in a central processor. 2
  • 3. 3
  • 4. 4
  • 5. 5
  • 6. DEVELOPING A PROGRAM  Plan  Code Programmer:  Good programmer – First plan then code  Large programming task – divide sub process  30 minutes planning could save hours of trying to make the code work properly.  Well planned code is not only more likely to be correct (or at least closer to correct), but is also easier to understand—and thus fix. 6
  • 7. ADD TWO NUMBER  Plan –  Declare two numbers  Give values to these two number  Store the output of these two added number, so need third variable – have to declare 3 variable.  Logically think – c=a+b;  Display the c value. Code int a=10,b=20,c; c=a+b; print the c value: = 30 Output: 30 7
  • 8. PROGRAMMING  Computer programming (often shortened to programming) is a process that leads from an original formulation of a computing problem to executable computer programs  Programming involves activities such as analysis, developing understanding, generating algorithms, verification of requirements of algorithms including their correctness and resources consumption, and implementation (commonly referred to as coding) of algorithms in a target programming language.  Source code is written in one or more programming languages.  The purpose of programming is to find a sequence of instructions that will automate performing a specific task or solving a given problem.  The process of programming thus often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic. 8
  • 9. PDLC  1. Analyze the problem  Precisely define the problem to be solved, and write program specifications – descriptions of the program’s inputs, processing, outputs, and user interface.  Eg : Problem : To find the sum of natural numbers Inputs : 2 positive numbers Processing : Adding first number and second number and storing/Print the result  User Interface : Any Programming Language (C compiler) 9
  • 10. PDLC  2. Design the program  Develop a detailed logic plan using a tool such as pseudo code, flowcharts, object structure diagrams, or event diagrams to group the program’s activities into modules;  Devise a method of solution or algorithm for each module; and test the solution algorithms.  10
  • 11. PDLC  3. Code the program  Translate the design into an application using a programming language or application development tool by creating the user interface and writing code; include internal documentation  – comments and remarks within the code that explain the purpose of code statements. 11
  • 12. #include<stdio.h> main() { int A, B, TOTAL; // Declare the input variables printf(“ Enter the first number”); scanf(%d”, &A); // Get the first input from the user printf(“ Enter the Second number”); scanf(%d”, &B); // Get the second input from the user TOTAL=A+B; // Add the numbers and store it in a variable printf(“ The Sum of Two numbers is %d”,TOTAL); // Print the output getch() ; } 12
  • 13. PDLC  4. Test and debug the program  Test the program, finding and correcting errors (debugging) until it is error free and contains enough safeguards to ensure the desired results.  5. Formalize the solution  Review and, if necessary, revise internal documentation; formalize and complete end- user (external) documentation  6. Operate and Maintain the program  Provide education and support to end users; correct any unanticipated errors that emerge and identify user-requested modifications (enhancements). Once errors or enhancements are identified, the program development life cycle begins again at Step 1. 13
  • 14. ALGORITHM  An algorithm is a set of instructions for solving a problem or accomplishing a task. (or)  An algorithm is an effective method and self-contained step- by-step set of operations to be perform a task in finite amount of time and space. Level of description:  High-level description -algorithm, ignoring the implementation details.  Implementation description- way the implementation is done  Formal description- a finite sequence of instructions to solve some problem 14
  • 15. CHARACTERISTICS  Instruction precise and unambiguous  Finite time  Not be repeated indefinitely  Optimal results – according to input  Unique solution  Finite number of steps  Meaningful information  Easy for understanding – begginer 15
  • 16. ALGORITHM WRITING 1. Get a clear understanding of the problem statement. 2. Proceed in a step by step fashion. 3. Divide the job into parts. 4. Include variables and their usage and define expressions. 5. Outline each loop 6. Include action statements. 7. Work outwards from the Action Statements, figuring out how each parameter will be determined each time the loop goes around 8. Go back to step number if loop or condition fails. 9. Use jump statement to jump from one statement to another. 10. Try to avoid unwanted raw data in algorithm. 11. Use break and stop to terminate the process. 16
  • 17. EXAMPLE:  Algorithm to find area of a circle 1. Start 2. Input the value of radius R 3. Let PI=3.14 4. Calculate area=PI*R*R 5. Print area 6.End 17
  • 18. FLOWCHART How to describe an animal to baby? color,size, etc – not understand Show picture – Now – baby understood “ PICTURES TALKS MORE THAN WORDS’ Like flowcharts - graphical representation of computer programs. 18
  • 19. FLOWCHARTS CONT’  A flowchart is a visual representation of the sequence of steps and decisions needed to perform a process.  Flowcharts use special shapes to represent different types of actions or steps in a process. Types : I. Sequential Structure – sequential order II. Selective Structure – condition expression (T/F) III. Looping Structure – Iteration – repeatedly check condition until false 19
  • 25. 25
  • 26. On-page Connector Connects two or more parts of a flowchart, which are on the same page. Off-page Connector Connects two parts of a flowchart which are spread over different pages. 26
  • 27. GUIDELINES  Understand a system before flowcharting it.  Flowchart can have only one start and one stop symbol  Identify the entities, such as departments, job functions, or external parties that are to be flowcharted.  divide the flowchart into columns, label each column  Use standard flowcharting symbols  Clearly label all symbols  Use arrowheads on all flow lines.  Try to use only one page per flowchart  On-page connectors are referenced using numbers  Off-page connectors are referenced using alphabets  General flow of processes is top to bottom or left to right  Arrows should not cross each other  Place the name of the flowchart, the date it was prepared, and the designer's name on each page of the flowchart. 27
  • 28. HOW TO DRAW FLOWCHART  Input is Number1, Number2  Output is stored in Sum  Concentrate on the symbols used. 28
  • 29. FLOWCHART ADVANTAGES  Flowcharts are easier to understand compare to Algorithms and Pseudo code.  It helps us to understand Logic of given problem.  It is very easy to draw flowchart in any word processing software like MS Word.  Using only very few symbol, complex problem can be represented in flowchart.  Software like RAPTOR can be used to check correctness of flowchart drawn in computers.  Flowcharts are one of the good way of documenting programs.  It helps us in debugging process. 29
  • 30. FLOWCHART DISADVANTAGES  Manual tracing is needed to check correctness of flowchart drawn on paper.  Simple modification in problem logic may leads to complete redraw of flowchart.  Showing many branches and looping in flowchart is difficult.  In case of complex program/algorithm, flowchart becomes very complex and clumsy.  Modification of flowchart is sometimes time consuming. 30
  • 31. PSEUDO CODE  A notation resembling a simplified programming language, used in program design.  An outline of a program, written in a form that can easily be converted into real programming statements.  Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules. It is simply one step - an important one - in producing the final code  Pseudocode is a "text-based" detail (algorithmic) design tool.  Include control structures such as WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE, which are present in many high level languages 31
  • 32. PSEUDO GUIDELINES : RULES FOR PSEUDOCODE  Write only one statement per line  Capitalize initial keyword  Indent to show hierarchy  End multiline structures  Keep statements language independent 32
  • 33. GUIDELINES CONT’  1. Write only one statement per line:  READ a,b  2. Capitalize initial keyword  READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL 3 3. Indent to show hierarchy SEQUENCE - all starting in the same column. SELECTION - indent the statements that fall inside the selection structure, but not the keywords that form the selection LOOPING- indent the statements that fall inside the loop, but not the keywords that form the loop 33
  • 34. GUIDELINES CONT’  4. End multiline structures  how the IF/ELSE/ENDIF is constructed above. The ENDIF (or END whatever) always is in line with the IF (or whatever starts the structure).  5. Keep statements language independent  to write in whatever language you are most comfortable with.  if you are SURE it will be written in that language, then you can use the features. If not, then avoid using the special features. 34
  • 35. BENEFITS/ADVANTAGES OF PSEUDOCODE:  Can be done easily on a word processor Easily modified  Implements structured concepts well  Clarify algorithms in many cases.  Impose increased discipline on the process of documenting detailed design. Provide additional level at which inspection can be performed.  Help to trap defects before they become code.  Increases product reliability.  May decreases overall costs.  It can be easily modified as compared to flowchart.  Its implementation is very useful in structured design elements.  It can be written easily.  It can be read and understood easily.  Converting a pseudocode to programming language is very easy as compared with converting a flowchart to programming language. 35
  • 36. LIMITATIONS/DISADVANTAGES OF PSEUDO CODE:  It's not visual  Create an additional level of documentation to maintain.  Introduce error possibilities in translating to code.  May require tool to extract pseudocode and facilitate drawing flowcharts.  There is no accepted standard, so it varies widely from company to company  We do not get a picture of the design.  There is no standardized style or format, so one pseudocode may be different from another.  For a beginner, it is more difficult to follow the logic or write pseudocode as compared to flowchart. 36
  • 37. EXAMPLE FOR PSEUDO CODE BEGIN READ A,B IF(A>B) PRINT A ELSE PRINT B ENDIF END 37
  • 38. PROGRAM CONTROL STRUCTURE  Control Structures are just a way to specify flow of control in programs.  Analyze the flow control  Act as a decision maker in computing Basic Terminology: 1) Precondition (Entry control) - state of variables before entering a control structure. 2) Post condition (Exit control)- state of variables after the algorithm is run 38
  • 39. BASIC CONTROL STRUCTURE  Sequential  Selection / conditional / Decision control statements  Looping /Iteration/ Repetition 39
  • 42. LOOPING  for(Expression 1; Expression 2; Expression 3){  //code to be executed  } 42 #include<stdio.h> int main(){ int i=0; for(i=1;i<=10;i++){ printf("%d n",i); } return 0; } 1 2 3 4 5 6 7 8 9 10
  • 43. 43
  • 44. DECISION MAKING  if statement  if..else statements  nested if statements  if-else-if ladder  switch statements  Jump Statements:  break  continue  goto  return 44
  • 45. IF  int main() {  int i = 10;   if (i > 15)  {  printf("10 is less than 15");  }   printf("I am Not in if");  } 45
  • 46. IF ELSE  int main() {  int i = 20;   if (i < 15){   printf("i is smaller than 15");  }  else{   printf("i is greater than 15");  }  return 0;  } 46
  • 47. // C program to illustrate nested-if statement #include <stdio.h> int main() { int i = 10; if (i == 10) { // First if statement if (i < 15) printf("i is smaller than 15n"); // Nested - if statement // Will only be executed if statement above // is true if (i < 12) printf("i is smaller than 12 toon"); else printf("i is greater than 15"); } return 0; 47
  • 48. NESTED-IF ELSE STATEMENT #include <stdio.h> int main() { int i = 20; if (i == 10) printf("i is 10"); else if (i == 15) printf("i is 15"); else if (i == 20) printf("i is 20"); else printf("i is not present"); } 48
  • 49. BREAK  #include<stdio.h>  #include<stdlib.h>  void main ()  {  int i;  for(i = 0; i<10; i++)  {  printf("%d ",i);  if(i == 5)  break;  }  printf("came outside of loop i = %d",i);   }  o/p :0 1 2 3 4 5 came outside of loop i = 5 49
  • 50. CONTINUE 50  //loop statements  continue;  //some lines of the code which is to be skipped  #include<stdio.h>  void main ()  {  int i = 0;  while(i!=10)  {  printf("%d", i);  continue;  i++;  }  }  Output :infinite loop
  • 51.  Syntax1 | Syntax2  ----------------------------  goto label; | label:  . | .  . | .  . | .  label: | goto label; 51
  • 52. GOTO // C program to print numbers // from 1 to 10 using goto statement #include <stdio.h> // function to print numbers from 1 to 10 void printNumbers() { int n = 1; label: printf("%d ",n); n++; if (n <= 10) goto label; } // Driver program to test above function int main() { printNumbers(); return 0; } 52  #include <stdio.h>  int main()  {  int num,i=1;  printf("Enter the number whose t able you want to print?");  scanf("%d",&num);  table:  printf("%d x %d = %dn",num,i,nu m*i);  i++;  if(i<=10)  goto table;  }  Enter the number whose table you want to print?10 10 x 1 = 10 10 x 2 = 20 10 x 3 = 30 10 x 4 = 40 10 x 5 = 50 10 x 6 = 60 10 x 7 = 70 10 x 8 = 80 10 x 9 = 90 10 x 10 = 100
  • 53. // C code to illustrate return // statement #include <stdio.h> // non-void return type // function to calculate sum int SUM(int a, int b) { int s1 = a + b; return s1; } // returns void // function to print void Print(int s2) { printf("The sum is %d", s2); return; } 53 int main() { int num1 = 10; int num2 = 10; int sum_of = SUM(num1, num2); Print(sum_of); return 0; } Output: The sum is 20
  • 54. SWITCH switch(expression){ case value1: //code to be executed; break; //optional case value2: //code to be executed; break; //optional ...... default: code to be executed if all cases are not matched; } 54 Rules for switch statement in C language 1) The switch expression must be of an integer or character type. 2) The case value must be an integer or character constant.
  • 55. 55
  • 56. SWITCH  #include<stdio.h>  int main(){  int number=0;  printf("enter a number:");  scanf("%d",&number);  switch(number){  case 10:  printf("number is equals to 10 ");  break;  case 50:  printf("number is equal to 50") ;  break; 56  case 100:  printf("number is equal to 100");  break;  default:  printf("number is not equal to 10, 50 or 100");  }  return 0;  }  Output :  enter a number:4 number is not equal to 10, 50 or 100
  • 57. LOOP 57  FOR  NESTED FOR  WHILE  DO WHILE
  • 58. FOR  for(Expression 1; Expression 2; Expression 3){  //code to be executed  } 58 #include<stdio.h> int main(){ int i=0; for(i=1;i<=10;i++){ printf("%d n",i); } return 0; } 1 2 3 4 5 6 7 8 9 10
  • 59. NESTEAD LOOP #include<stdio.h> int main(){ int i=1,j=1;//initializing a local variable for(i=1;i<=3;i++){ for(j=1;j<=3;j++){ printf("%d &dn",i,j); if(i==2 && j==2){ break;//will break loop of j only } }//end of for loop return 0; } 59 1 1 1 2 1 3 2 1 2 2 3 1 3 2 3 3
  • 60. WHILE  while(condition){  //code to be execut ed  }  #include<stdio.h>  int main(){  int i=1;  while(i<=10){  printf("%d n",i);  i++;  }  return 0;  } 60 Output : 1 2 - - 10
  • 61. DO WHILE  do{  //code to be execute d  }while(condition);  #include<stdio.h>  int main(){  int i=1;  do{  printf("%d n",i);  i++;  }while(i<=10);  return 0;  } 61  Output:  1  2  -  -  10