structural programming assignment
structural programming assignment
DATE OF SUBMISSION:29-01-2025
GROUP 3 MEMBERS:
b. Efficient - Fast and simple; runs with minimal resources; ensures high execution speed in
critical systems.
c. Procedural - Organized into functions that executes a series of commands to perform tasks
e. Easy Debugging - Tools like Ctrl + D help in error detection and debugging.
Characters used to create spaces, such as tabs in source code, to improve readability.
3. Tokens in C
i)Definition:
-Keywords: Reserved words with predefined meaning (e.g., while, if, for).
4. Escape Sequences
\n: Newline
\b: Backspace
\\: Backslash
- Example: int* ptr = &age; // Points to the location of the variable age.
6) Functions:
- Functions are the fundamental building blocks of C. They help organize programs into sections,
making them modular and reusable.
Example:
int main() {
printf("Hello world");
return 0;
6)Variables:
Examples:
- Syntax:
Example:
int a = 5;
type variable Name = value;
A variable name must begin with a letter (a-z or A-Z) or an underscore (_).
ii)Subsequent Characters:
After the first character, the variable name can contain letters, digits (0-9), and underscores (_).
The name of the variable cannot be a keyword in C (e.g., int, return, if, while).
iv)Case Sensitivity:
C is case-sensitive, meaning age, Age, and AGE are considered different variables.
7. What is a Constant?
Example:
- Decimal Constants
- Real/Floating Constants
#define PI 3.14159
Code example
int main() {
scanf("%f", &radius);
// Calculate the area of a circle using the formula: Area = PI × radius × radius
printf("The area of the circle with radius %.2f is %.2f\n", radius, area);
return 0; // Indicates the program executed successfully