1/56
Flashcards covering key concepts from Lecture 1 of NMK10603: Introduction to C Programming. They address course logistics, algorithms, C syntax elements, data types, operators, I/O, debugging, and testing.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are the two delivery modes for this C Programming course?
Online and face-to-face sessions.
List the weeks scheduled for online lectures in this course.
Week 1 (27/3/2023), Week 2 (3/4/2023), Week 5 (1–5/5/2023, exact date TBC), and Week 14 (3/7/2023).
Name the three Course Outcomes (COs) for NMK10603.
CO1 – Define and describe programming concepts and principles; CO2 – Apply tools for coding, compiling, executing and debugging; CO3 – Develop software solutions for engineering-related problems.
How is the overall evaluation for the course distributed?
Test 10 %, Lab Assessments 1–3 (10 %, 15 %, 15 %), Log book 10 %, Final Exam 40 %.
Besides learning C syntax, what three skills does this course emphasize?
Problem solving, analytical skills, and applying C to solve problems.
Define an algorithm.
A step-by-step set of instructions needed to accomplish a specific task.
Give two common ways to write an algorithm.
Pseudocode (numbered sentences) and flow charts (visual diagrams).
In a flow chart, what shape represents Start/End?
The terminator symbol (rounded rectangle/oval).
What is the golden rule about arrows for a Process symbol in a flow chart?
Each Process must have exactly one incoming arrow and one outgoing arrow.
State the formula for the area of a triangle used in the sample task.
Area = 0.5 × base × height.
What are the three general steps to solve a programming problem according to the lecture?
1) Analyze the problem, 2) Develop an algorithm, 3) Convert the algorithm to actual code.
Give the pseudocode (in brief) for calculating triangle area.
Read base and height; compute area = 0.5 × base × height; print area.
Which standard C library header is required for basic input/output?
stdio.h
In C, which function is typically used to read formatted input?
scanf()
What is a computer program as defined in the lecture?
A set of instructions written in a programming language that directs the computer to perform a specific task and is free from errors.
List the five general phases of system development.
Analysis, Design, Implementation, Testing, Deployment.
Name the four step cycle shown for programming with an IDE.
Coding → Compile/Build → Run → Debug.
Who is a programmer?
A person who writes program code and knows programming basics such as variables, loops, and selections.
Define a programming language.
A set of keywords and syntax rules that can be understood by a computer to create programs.
List any four elements of a programming language mentioned.
Keywords/Reserved words, Identifiers, Variables, Constants, Arithmetic operators, Logical operators, Comments, Syntax.
What is the difference between a keyword and a reserved word?
A keyword has a predefined meaning in the language; a reserved word is set aside for special use and cannot be re-purposed as identifiers.
Provide three examples of C keywords/reserved words.
int, if, while (others acceptable: for, double, include, main, etc.).
What is syntax in programming?
The exact set of rules for arranging words and symbols to form valid instructions; violating them causes syntax errors.
Write the basic skeleton of a minimal C program as shown in class.
void main() {
// all coding here
}
Explain what a variable is in C.
A named location in memory that can hold a value which may change during program execution.
Are variable names in C case-sensitive?
Yes, e.g., myNumber and mynumber are different identifiers.
List three rules for valid variable names in C.
Must start with a letter or underscore; can contain letters, digits, or underscores; cannot contain spaces or reserved words.
What is a constant?
A value that does not change during program execution; can be named (via const or #define) or unnamed (literal).
Show the syntax of a C block comment and a line comment.
Block: /* comment */ ; Line: // comment
What symbol begins every preprocessor directive?
The hash or pound symbol (#).
Give two common preprocessor directives and their purposes.
Match the header file to its typical use: stdio.h, stdlib.h, string.h, math.h.
stdio.h – standard I/O; stdlib.h – conversions, memory allocation, rand; string.h – string processing; math.h – math functions.
State three things a data type determines.
Type of data stored, number of bytes in memory, range of values, and allowed operations.
List the four data-type modifiers supported in C.
short, long, signed, unsigned.
What is the memory size of a standard int on the lecture slide?
32 bits / 4 bytes.
According to Hungarian notation, what prefix is used for a double variable?
d (e.g., dHeight).
Declare and initialize a named constant of type float with value 0.05.
const float fTax = 0.05;
List the five categories of operators introduced.
Arithmetic, Relational, Logical, Compound assignment, Bitwise.
Provide the arithmetic operators available in C.
What is the modulus operator used for?
To obtain the remainder of integer division (e.g., 20 % 3 → 2).
What relational operator checks for inequality?
!=
Write the logical AND and OR operators in C.
&& (AND) and || (OR).
What is the outcome type of relational and logical expressions?
Boolean (true or false).
Complete the truth table entry: true AND false = ?
false.
Give the compound assignment equivalent of val = val + 1.
val += 1; (or val++;).
Explain the difference between prefix and postfix increment.
Prefix (++i) increments before the value is used; postfix (i++) uses the value first then increments.
List the highest-precedence operator group in the provided table.
Unary operators ! + - (prefix).
Which function is used to display formatted output in C?
printf().
Give the format specifier for an int and for a double.
%d for int; %lf for double.
What escape sequence produces a new line?
\n
Why must addresses be supplied to scanf?
Because scanf stores input values into the memory locations of variables, so &variable is needed.
Define a bug and debugging.
A bug is an error in code; debugging is the process of finding and eliminating errors.
List the three main types of program errors.
Compile-time errors, Run-time errors, Logical errors.
What kind of error is dividing by zero?
Run-time error (fatal error caused by the OS during execution).
Why are logical errors the hardest to detect?
Because the program runs without crashing, but produces incorrect results noticeable only upon careful checking.
What is a test case?
A set of inputs with predicted outputs used to verify program correctness.
Name the three common categories of test cases mentioned.
Functionality, Performance, Usability test cases.