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

Develop Program Retake 3

The document outlines a written assessment for developing a computer program, detailing various programming concepts and tasks. It includes questions on the program development life cycle, flowchart creation, pseudocode writing, and programming language selection factors. Additionally, it provides examples of C programming code and flowcharts to illustrate key concepts.

Uploaded by

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

Develop Program Retake 3

The document outlines a written assessment for developing a computer program, detailing various programming concepts and tasks. It includes questions on the program development life cycle, flowchart creation, pseudocode writing, and programming language selection factors. Additionally, it provides examples of C programming code and flowcharts to illustrate key concepts.

Uploaded by

vinncenciaawuor
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

THE MAWEGO NATIONAL POLYTECHNIC

Develop Computer Program


WRITTEN ASSESSMENT –RE-ASSESSMENT
1 Hours
Answer all questions

1. a) Discuss the seven stages of program development life cycle. (14 Marks)
b) Table 1 shows the criteria used by Tusome Technical Institute to award grades to
students. Use it to answer the question that follows;

Points Grade
1 Distinction
2 Credit
3 Pass
4 Fail
Table 1
Write a program in C that would prompt a user to enter the points obtained by a student.
The program then displays the corresponding grade. Use switch statement.
(6
Marks)
2. a) Draw a flowchart for a program that can be used to prompt the user to enter two
numbers, find the sum and average of the two numbers and then display the output on the
screen. (6
Marks)
b) Write a pseudocode that would prompt the user to enter the Length and Width of a
rectangle, calculate the Area and Perimeter, then display the result. (8 Marks)
c) With the aid of flowcharts, distinguish between the IF statement and IF...ELSE
statement. (6 Marks)
3. a) Describe five factors one should consider when selecting a programming language.
(10 Marks)
b) Explain the structure of a C program. (10 Marks)

ASSESSOR GUIDE

. a) Seven Stages of Program Development Life Cycle (14


Marks)

1. Problem Definition: Understanding and outlining what the program is supposed to do,
including user needs and expected outcomes.
2. Program Design: Planning the solution using tools like flowcharts, algorithms, or
pseudocode. Focuses on logic and structure.
3. Coding/Implementation: Writing the actual program using a chosen programming
language (e.g., C).
4. Compilation: Translating the source code into machine code using a compiler. Syntax
errors are detected at this stage.
5. Testing and Debugging: Running the program with test data to identify and fix errors
(bugs), including logic and runtime errors.
6. Documentation: Writing manuals or inline comments to help users and future developers
understand the system.
7. Maintenance: Updating the program to fix bugs, add features, or adapt to new
hardware/software environments.

1. b) C Program Using Switch Statement (6 Marks)


c
CopyEdit
#include <stdio.h>

int main() {
int points;

printf("Enter the points (1-4): ");


scanf("%d", &points);

switch(points) {
case 1:
printf("Grade: Distinction\n");
break;
case 2:
printf("Grade: Credit\n");
break;
case 3:
printf("Grade: Pass\n");
break;
case 4:
printf("Grade: Fail\n");
break;
default:
printf("Invalid input. Enter a number between 1 and 4.\n");
}

return 0;
}

2. a) Flowchart – Sum and Average of Two Numbers (6 Marks)


Flowchart Description (Textual representation)
csharp
CopyEdit
[Start]
|
v
[Input Num1, Num2]
|
v
[Sum = Num1 + Num2]
|
v
[Average = Sum / 2]
|
v
[Display Sum, Average]
|
v
[End]

You can draw this using standard flowchart symbols: parallelograms for I/O, rectangles for
processes, and ovals for start/end.

2. b) Pseudocode – Area and Perimeter of a Rectangle (8 Marks)


mathematica
CopyEdit
START
PROMPT "Enter the Length: "
READ Length
PROMPT "Enter the Width: "
READ Width
Area ← Length * Width
Perimeter ← 2 * (Length + Width)
DISPLAY "Area = ", Area
DISPLAY "Perimeter = ", Perimeter
END

2. c) Distinguishing Between IF and IF...ELSE Statements with


Flowcharts (6 Marks)
IF Statement Flowchart
sql
CopyEdit
[Start]
|
v
[Condition]
|
v (True)
[Do Task]
|
v
[End]

(False)
|
v
[End]
IF...ELSE Statement Flowchart
less
CopyEdit
[Start]
|
v
[Condition]
/ \
v v
[Task1] [Task2]
\ /
v v
[End]

Difference:

 IF only executes code when the condition is true.


 IF...ELSE executes one block if true, another block if false.

3. a) Five Factors to Consider When Selecting a Programming


Language (10 Marks)

1. Nature of the Application: Some languages are better for web (e.g., JavaScript), system
programming (e.g., C), or enterprise apps (e.g., Java).
2. Platform Compatibility: Whether the language runs on the required OS or environment.
3. Performance Requirements: Some applications need faster execution (e.g., C/C++ for
games or real-time systems).
4. Ease of Use and Learning Curve: How easy it is to learn and use the language (Python
is easier than C++).
5. Community Support and Libraries: Languages with strong communities offer more
help, tools, and libraries (e.g., Python, Java).

3. b) Structure of a C Program (10 Marks)

A basic structure of a C program includes:

1. Preprocessor Directives:

c
CopyEdit
#include <stdio.h>
Tells the compiler to include standard input-output library.

2. Main Function:

c
CopyEdit
int main() {
// statements
return 0;
}

Every C program must have a main() function as the entry point.

3. Variable Declarations:

c
CopyEdit
int a, b;

Declaring variables used in the program.

4. Executable Statements:
These are the actions the program takes, such as calculations or I/O.
5. Return Statement:
return 0; indicates successful completion of the program.

Example:
c
CopyEdit
#include <stdio.h>

int main() {
int a = 5, b = 10, sum;
sum = a + b;
printf("Sum: %d", sum);
return 0;
}

You might also like