He needs to enter student IDs and students'''' grades and store this information into 2 separate arrays integer array for IDs and float array for grades.. Variables, data types -Integer arr
Introduction (P1, M1)
General concepts (P1)
Procedural programming is derived from imperative programming Its concepts are based on procedure calls, a series of computational steps to be carried out The execution of the instructions takes place step by step according to direct instructions from a human telling the computer how to achieve a goal through processes Procedural programming focuses on the process rather than data (Object-oriented Programming) and function (Functional Programming)
Fundamentally, procedural code is the code that tells a device how to do a task in logical steps This paradigm employs a top-down linear approach and treats data and methods as distinct entities To do computations, it uses procedures or subroutines
Imperative programming is another name for procedural programming b) Advantages and disadvantages of C programming
-Building block for many other programming languages -Powerful and efficient language
-Implementation of algorithms and data structures
-Low level of abstraction c) Procedural language types
Example: FORTRAN, ALGOL, COBOL, BASIC, PASCAL, C/C++, Java, etc
The first major procedural programming languages around 1957-1964 were FORTRAN, ALGOL, COBOL, PL/I and BASIC The procedural Programming paradigm is one of the first paradigms to emerge in the computational world.
Java and C/C++ are popular procedural languages these days.
Characteristics (M1)
-A top-down method is used in procedural programming
-The program is organized into functions, which are blocks of code that each execute a specified purpose -Real-world processes are modeled as 'procedures' that operate on 'data' in procedural systems
-Data and functions are separate from one another
-In a software, data is free to move about
-It's simple to follow a program's logic
-By invoking another function, a function can have access to its data.
Features (M1)
It is a name-assigned instruction A pre-defined function such as "charAt()" searches for a character in a string at a specific position There are more pre-defined functions to help with competitive programming b) Local Variables
Local variables are declared in the method's main structure Only within the method will you be able to access the local variable Local variables are defined as follows in the C programming language: d) Global Variables
They are declared outside of all methods so that they can be accessed from anywhere in the code Allow you to become acquainted with global variables in C: e) Programming libraries
A programming library is a collection of previously written code that can be used whenever a programmer needs it f) Modularity
It is a broad term that refers to the development of software in such a way that individual modules can be created, often with a standard interface to allow modules to communicate with one another g) Parameter passing
It is essentially a system for passing parameters to functions, subroutines, or processes The terms "pass by value," "pass by reference," "pass by result," "pass by value-result," and "pass by the name" are all used to pass parameters
Pass array (C only) Pass by reference (C only) pass by value (C/C++)
Analysis (P2)
Variables, data types
-Integer array IDs[]: store students’ IDs
-Integer variable n: option indicator for the program’s menu
-Integer variable i: number of students and also size of IDs[] and grades[] arrays
-Integer variable d: array index indicator
-float array grades[]: store students’ grades
-float variables min: lowest grade
-float variables max: max grade.
Data structures
-Switch case can be used in the program's option menu to start a case (sub-function)
-While loop is required for the program to return to the main menu when a sub-function is completed and only end the program when the user selects the option to do so b) Case 1
-For loop can be used to input student IDs and grades according to the number of students declared c) Case 2
-For loop can be used to display every student's IDs and grades according to the number of students declared
-If condition can be used to check the student's score corresponds to that student's ID number d) Case 3
-For loop can be used to create a loop that continuously checks and compares the scores of all students in turn to find the highest and lowest scores
-If condition can be used to compare each student s grade with the highest and lowest score ’
Design (P3,M2)
Use-case and WBS (P3)
Flowchart (P3)
If the user enters a number between 1 and 3, a sub-function corresponding to that number will run, and when that sub-function is finished, the user will be sent back to the options menu to input another number, as long as the user does not enter the number 4 If the number entered was not between 1 and 4, a notice stating "invalid option" would appear, prompting the user to return to the menu and enter a new number The user can command the program to stop when the number 4 is entered b) Input students’ IDs and grades sub-function
The variable I will be used to represent the number of students for whom the user wants to submit their IDs and grades, as well as the size of the IDs [] and grades [] arrays Students' IDs are stored in the IDs [] array, while their grades are stored in the grades [] array The d variable is the element index indication for both arrays; depending on which array it's in, each element holds the ID or grade of one student Because index numbering begins at 0, the last index number in an array with a large number of entries will be (i-1) The user initially enters a number I which determines the size of the two arrays stated The user can then enter the IDs and grades of students into the arrays from the first element using a loop When the user enters the value for the last element of both arrays, the sub-function will terminate c) Display all student’s IDs and grades sub-function
All arrays and variables will be passed to this sub-function to display all students' IDs and grades The elements of both arrays will then be displayed in order from the first to the last index using a loop d)Display IDs and grades of students with highest and lowest grades sub-function
This function will also accept variables and arrays The highest and lowest grades will be the variables max and min, but their values must first be set as the first element of the grades [] to serve as a baseline for later comparison Starting at index 1, the first loop will go through each element of the grades [] array and compare it to the min and max values When an element is larger than max, the new value of max is assigned to that element; when an element is smaller than min, the new value of min is assigned to that element When the loop has finished going through all of the elements in the array, the highest grade is stored at max and the lowest grade is stored at min The sub-function will then enter another loop, this time going through the grades [] array starting at index 0 and checking if the current element is equal to min or max If it is, that element will be displayed, along with the element with the same index in the IDs [] array.