Shane Graded Work
Shane Graded Work
Graded Work
Task:
1)
a) Declarative Programming
Declarative programming focuses on describing what the program should accomplish rather
than how to do it. It often eliminates the need for explicit control flow.
Example: SQL (for database queries) and Prolog (for logic programming).
b) Logic Programming
Logic programming is based on formal logic. Instead of writing sequences of instructions, the
programmer defines facts and rules, and the system derives conclusions from them.
c) Concurrent Programming
d) Reactive Programming
e) Dataflow Programming
In this paradigm, programs are represented as a network of data flowing between operations.
It is widely used in parallel computing and stream processing.
High-level programming languages need to be translated into machine code before execution.
Different tools help in this process:
a) Assemblers
b) Compilers
Compilers translate the entire source code of a high-level programming language into
machine code or an intermediate language before execution. The generated code is often
optimized for performance.
Example:
o C Compiler (GCC, Clang) → Compiles C code into machine code.
o Java Compiler (javac) → Translates Java source code into bytecode.
Virtual Machines provide an abstraction layer between the compiled program and the
underlying hardware. They execute an intermediate representation of code, allowing
portability across different systems.
Example:
o Java Virtual Machine (JVM) → Runs Java bytecode.
o Python Virtual Machine (PVM) → Executes Python bytecode.
d) Interpreters
Interpreters translate and execute code line by line, without producing a separate executable
file. This makes debugging easier but often results in slower execution compared to compiled
programs.
Example:
o Python Interpreter (CPython) → Executes Python scripts.
o JavaScript Engine (V8, SpiderMonkey) → Executes JavaScript in browsers.
3)
1- Sequence Classwork
Tasks 1
#include <stdio.h>
int main() {
if (num2 != 0) {
} else {
return 0;
}
Task 2
#include <stdio.h>
int main() {
scanf("%f", &length);
scanf("%f", &width);
return 0;
2- Selection
Task 1
#include <stdio.h>
int main() {
int number;
scanf("%d", &number);
if (number % 2 == 0) {
} else {
return 0;
Tasks 2
#include <stdio.h>
int main() {
int score;
char grade;
scanf("%d", &score);
grade = 'B';
grade = 'C';
grade = 'D';
} else {
grade = 'F';
return 0;
Task 3
#include <stdio.h>
int main() {
int age;
scanf("%d", &age);
printf("Teenager\n");
printf("Adult\n");
printf("Senior\n");
} else {
printf("Invalid age\n");
return 0;
3- Iteration
Task 1
#include <stdio.h>
int main() {
printf("%d\n", i);
return 0;
Task 2
```c
#include <stdio.h>
int main() {
scanf("%d", &number);
sum += i;
return 0;
Task 3
```c
#include <stdio.h>
int main() {
int num;
return 0;