0% found this document useful (0 votes)
46 views

Comp 228 Short Notes

Uploaded by

David Tiisa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Comp 228 Short Notes

Uploaded by

David Tiisa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

The act of defining a problem; determining the cause of the problem; identifying, prioritizing, and selecting alternatives

for a solution; and implementing a solution.


Basic steps in solving a problem:
 Defining the problem.
 Generating alternatives.
 Evaluating and selecting alternatives.
 Implementing solutions.
Techniques in problem solving
1. Divide and conquer strategy
2. Trial and error strategy
3. Top down strategy
4. Bottom up strategy
If…else- It executes a section of code if a specified condition is true and optionally executes another section if
the condition is false.--
if (condition)
{
// code to be executed if condition is true
}
else
{
// code to be executed if condition is false
}
while Loop-- is used to repeat a block of code as long as a specified condition remains true.
while (condition)
{
// code to be executed repeatedly as long as condition is true
}

switch case Statement--- allows a variable to be tested for equality against a list of values
switch (expression)
{
case constant1:
// code to be executed if expression == constant1
break;
case constant2:
// code to be executed if expression == constant2
break;
default:
// code to be executed if expression doesn't match any case
}
Files used in c program
Source File- This file contains the source code of the program. The file contains C source code that defines the main
function & maybe other functions.
Header File- A header file is a file with extension .h which contains the C function declarations and macro definitions and
to be shared between several source files.
Object File- An object file is a file containing object code, with an extension .o, meaning relocatable format machine
code that is usually not directly executable
Types of errors
a) Syntax Errors: Errors in syntax (grammar) of the program.
b) b) Semantic Errors: Errors in the meaning of the program.
c) c) Logical Errors: Errors in logic of the program. Compiler cannot diagnose these kinds of errors.
d) d) Runtime Errors: i) Insufficient memory ii)Floating exception e) Compile Errors: i) parse error ii)implicit declaration
iii) no matching function iv)Unsatisfied symbols v)incomplete type vi)cannot call member function vii)bad argument
viii)cannot allocate an object
situatios that may require an organization to develop a new program
 Operational Inefficiencies
 Market Demands and Consumer Needs:
 Regulatory Compliance:
 Technological Advancements:
 Security Enhancements
 Strategic Shifts
The following are six steps in the Program Development Life Cycle:
1. Analyze the problem. The computer user must figure out the problem, then decide how to resolve the problem
- choose a program.
2. Design the program. A flow chart is important to use during this step of the PDLC. This is a visual diagram of the
flow containing the program. This step will help you break down the problem.
3. Code the program. This is using the language of programming to write the lines of code. The code is called the
listing or the source code. The computer user will run an object code for this step.
4. Debug the program. The computer user must debug. This is the process of finding the "bugs" on the computer.
The bugs are important to find because this is known as errors in a program.
5. Formalize the solution. One must run the program to make sure there are no syntax and logic errors. Syntax are
grammatical errors and logic errors are incorrect results.
6. Document and maintain the program. This step is the final step of gathering everything together. Internal
documentation is involved in this step because it explains the reasoning one might of made a change in the program or
how to write a program.
Reasons for documentation
Code Maintenance and Updates:
Clarity and Communication:
Consistency and Standards Enforcement
Project Management:
Legal and Compliance Requirements:
Knowledge Preservation
Quality Assurance and Testing
Dispute Resolution and Understanding
Facilitating Reviews and Audits
 The top-down approach prioritizes high-level planning and decision-making, while the bottom-up approach
prioritizes the execution of individual tasks and the development of detailed knowledge.
Factors to consider when selecting technique to solve a problem
 Nature of the problem
 Familiarity with the technique
 Cost of the technique
 Reliability of the technique
 Efficiency of the technique
 Robustness of the technique
 Accuracy of the Technique
 Flexibility of the Technique
 while Loop:
initialize loop counter;
while (test loop counter using a condition/expression)
{
<Statement1>
<Statement2>

< decrement/increment loop counter>
}
 for Loop:
for (initialize counter; test counter; increment/decrement counter)
{
<Statement1>
<Statement2>

}
 do while Loop:
initialize loop counter;
do
{
<Statement1>
<Statement2>

}
while (this condition is true);

You might also like