DEFINITIONS
An algorithm is a step-by-step procedure or set of rules designed to perform a specific task or solve a particular problem. It is a precise and unambiguous description of a series of computational steps that produce a result or achieve a specific objective.
A pointer is a variable in programming that stores the memory address of another variable. It essentially "points to" the location in memory where the data is stored. Pointers are used for dynamic memory allocation, efficient array manipulation, and working with complex data structures.
In the context of programming and functions, a parameter is a variable or value that is passed into a function as input. It is a way to provide information to a function so that it can perform a specific task. Parameters are placeholders for the actual values or variables that will be passed into the function when it is called.
Static variables in programming refer to variables that retain their values between function calls. They are declared using the static keyword. Unlike local variables, static variables are initialized only once and persist throughout the program's execution. They are stored in a fixed memory location.
External variables are variables defined outside of any function in a program and can be accessed by multiple functions. They are typically declared at the beginning of a program or in a separate file, and their scope extends to the entire program. External variables are sometimes referred to as global variables.
Constants are values or variables whose values cannot be altered during the execution of a program. They are used to represent fixed values that should not be modified. In many programming languages, constants are declared using the const keyword, providing a way to make code more readable and maintainable by explicitly indicating that certain values are not intended to change
Stepwise refinement is a process used in software development where a complex problem or task is broken down into smaller, more manageable sub-problems or sub-tasks. Each sub-problem is then further refined into even smaller steps until the solution becomes clear and implementable. This iterative approach helps programmers tackle large problems methodically, allowing for better organization and understanding of the problem-solving process.
Programming language syntax refers to the set of rules and conventions that dictate the structure and format of valid statements and expressions in a programming language. Syntax defines how the various elements of the language, such as keywords, operators, variables, and punctuation, should be arranged to form correct and meaningful instructions for the computer to execute. Following the syntax rules is essential for writing code that the compiler or interpreter can understand and process.
Programming language semantics refers to the meaning or interpretation of valid statements and expressions in a programming language. Semantics define the behaviour and functionality of the language constructs in terms of their intended actions or effects when executed. It encompasses the rules and principles that govern the execution of code, including the effects of statements on program state, data manipulation, control flow, and interaction with the system environment.
Programming language vocabulary refers to the collection of keywords, identifiers, symbols, and other language elements that are recognized and used byprogrammers to write code in a particular programming language. It encompasses the reserved words, built-in functions, data types, and syntactic elements that constitute the building blocks of programs written in the language. Understanding and effectively utilising the language vocabulary are essential for expressing algorithms and solving problems using the language.
In programming, a constant is a fixed value that cannot be altered or modified during the execution of a program. Constants are used to represent fixed data or values that remain unchanged throughout the program's execution. They provide a way to define and use values that are known at compile time and do not need to be recalculated or reassigned during program execution. Constants can be of various types, such as numeric constants (e.g., integers, floating-point numbers), character constants (e.g., strings), or symbolic constants (e.g., named constants defined using #define or const declarations).
"%f" is a format specifier used for input and output operations with floating-point numbers in C.
the ampersand character (&) is used as the "address-of" operator. when you pass a variable to a function that expects a pointer (such as scanf in this case), you use the address-of operator (&) to pass the memory address of that variable. This allows the function to directly modify the content of the variable at that address.The &
operator in scanf
is used to pass the memory address of a variable to the function
The character used to terminate a string data type is the null character, represented by \0.
It is necessary to terminate strings in C to denote the end of the string data and to inform functions and routines that manipulate strings where the string ends. This termination allows functions like printf, scanf, and various string manipulation functions to accurately determine the length and boundaries of the string. Additionally, terminating strings enables proper memory allocation and prevents buffer overflow errors when working with strings.
Common Logical and Mathematical Operators:
Mathematical Operators:
% (Modulo): Returns the remainder of a division operation.
Example: 5 % 2 equals 1 (5 divided by 2 leaves a remainder of 1).
/ (Division): Divides one number by another.
Example: 10 / 5 equals 2.
Logical Operators:
!= (Not Equal To): Checks if two values are not equal. Returns true if they are different, false if they are the same.
Example: 7 != 5 is true, while 4 != 4 is false.
&& (Logical AND): Returns true if both operands are true, false otherwise.
Example: (5 > 3) && (7 > 2) is true, while (2 > 4) && (6 == 6) is false.
|| (Logical OR): Returns true if at least one operand is true, false only if both are false.
Example: (10 < 5) || (8 > 3) is true, while (1 == 2) || (0 != 0) is false.
== (Equal To): Checks if two values are equal. Returns true if they are the same, false if they are different