0% found this document useful (0 votes)
8 views5 pages

Structured Programming Assignment

Good for learners

Uploaded by

Song Benard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Structured Programming Assignment

Good for learners

Uploaded by

Song Benard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

STRUCTURED

PROGRAMMING
C Programming assignment by Mr.
Mugejjera Emmanuel
KAGIMU FELIX SAMUEL
21/U/07221/EVE

STRUCTURED PROGRAMMING
C PROGRAMMING ASSIGNMENT
KAGIMU FELIX SAMUEL

21/U/07221/EVE

1. LIST ATLEAST 20 PROGRAMMING LANGUAGES.


 JavaScript
 Python
 Java
 Hypertext Preprocessor (PHP)
 C
 C++
 Fortran
 COBOL
 Scala
 Prolog
 Perl
 Cascading Style Sheets (CSS)
 Structured Query Language (SQL)
 Swift
 Typescript
 C#
 Kotlin
 Rust
 Hyper Text Markup Language
 Ruby

2. TYPES OF ERRORS IN PROGRAMMING AND WRITE ABOUT EACH OF THEM.


a. THE SYNTAX ERRORS.
These are errors that occur during calculations when a program is executing or at a runtime.
This is when a code given doesn‟t follow the syntax rules of programming the language.

A case in point can be;


 Misspelling a statement or a word, eg writing “pint” instead of “print”.
 Using a variable before it has been declared.
 Missing brackets eg opening a bracket but not closing it.

For a program to continue running, such errors must be fixed first.


Syntax errors can be resolved with help of Interactive Development Environment debug tools and
manual code-checking best practices

b. LOGIC ERRORS
A logic error is an error in the way the program works. The program can run but doesn‟t do what it
is expected to do.
Logic errors can be cause by the programmer in the following ways;
 Incorrectly using logical operators, eg expecting a program to stop when the value of a
variable reaches 5 by using <=5. The error will occur when <5 is the operator used.
 Using incorrect program designs or sequence of statements such as performing a calculation
before assigning values to the variables.
 Incorrectly using brackets in calculations.
 Unintentionally creating a situation where an infinite loop may occur.
 Incorrectly using brackets in calculations.

NB: Unlike a syntax error, a logic error does not stop the program from running, nut the program
will run, but not function as expected.
Logic errors can be avoided by ensuring maximum communication among programmers and tests
should be written concurrently to test for errors earlier.

c. RUNTIME ERRORS
A runtime error is an error that occurs or takes place during the running of a program, and it is
likely to crush the program.
Such errors are only identified during the execution of the program, and can result from
mismatched data types and overflows.
KAGIMU FELIX SAMUEL
21/U/07221/EVE

 A case in point is when a program tries to access the sixth item in an array that only contains
five items.
Unlike the syntax and the logic errors, the runtime errors can crush the running programs.
Runtime errors can be avoided by having an effective bug reporting system and lots of user testing
to identify such issues and identify easily.

d. RESOURCE ERRORS
When a program causes the computer to use more resources than it has, it causes a resource error.
This error can cause the program to be bugged or the system to crash.

 A case in point is when a you right a loop that your code could never exit from, you could
eventually run out of resources.
To avoid these errors, users have to be aware of the resources programs while gathering data on
resource usage, including load testing apps and services. In this case, less resources maybe used.

e. ARITHMETIC ERRORS
An arithmetic error is a type of logic error but involves mathematics.
 An example is a division equation that involves dividing by zero, if parameters of a system
allow for the range of numbers to go down to zero, it can result into the program being
asked to do something impossible such as dividing by zero.

Such errors can be avoided by having functional tests. Functional tests always include edge-cases
like zero, or negative numbers which helps to stop arithmetic errors.

f. COMPILATION ERRORS
Compilation is where the high-level language converts into a low-level language that the computer
can understand.
A compilation error is the state when a compiler fails to compile a piece of computer program
source code due to errors in the compiler itself.
A compilation error can occur the compiler doesn‟t know how to turn the code into a low-level
language.

 An example is when compiling print(„hello‟ , the compiler would stop because it cant convert
this into low-level language because a closing bracket is expected at the end.

Compilation errors can be solved by checking statement by statement in the programming code and
also scrubbing output folders when cleaning projects.

3. THINK ABOUT FIVE TASKS OF YOUR CHOICE AND WRITE A PSEUDOCODE (STEPS)
ABOUT THEM.
a. AREA OF A TRIANGLE
Start
Input h , b
Calculate area
a = (h * b)/2
Output a
End

b. AREA OF SQUARE
Start
Input s
Calculate area
a = s^2
Output a
End

c. AREA OF A RECTANGLE
Start
Input l , w
Calculate area
a = l * w
Output a
End
KAGIMU FELIX SAMUEL
21/U/07221/EVE

d. VOLUME OF A SPHERE
Start
Input r
Calculate volume
v = (4/3) * PI * (r^3)
Output v
End

e. VOLUME OF A CUBOID
Start
Input l , w , h
Calculate volume
v = l * w * h
Output v
End

4. WRITE DOWN FIVE PROGRAMS TO WORDS OF YOUR CHOICE.

PROGRAM ONE.
#include<stdio.h>
int main()
{
printf(“hey”);
printf(“how are you ?\n”);
printf(“nice day.”);
return 0;
}
heyhow are you ?
nice day.

PROGRAM TWO.
#include<stdio.h>
int main()
{
printf(“c programming is good.”);
return 0;
}
c programming is good.

PROGRAM THREE.
#include<stdio.h>
int main()
{
printf(“teacher mugejjera is the best.”);
return 0;
}
teacher mugejjera is the best.

PROGRAM FOUR.
#include<stdio.h>
int main()
{
printf(“makerere university is the best.”);
return 0;
}
makerere university is the best.

PROGRAM FIVE.
#include<stdio.h>
int main()
{
printf(“pray everyday.\n”);
printf(“fasting is good.”);
return 0;
}
KAGIMU FELIX SAMUEL
21/U/07221/EVE

pray everyday
fasting is good.

You might also like