Introduction to C Programming – Lecture 1

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/56

flashcard set

Earn XP

Description and Tags

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.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

57 Terms

1
New cards

What are the two delivery modes for this C Programming course?

Online and face-to-face sessions.

2
New cards

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).

3
New cards

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.

4
New cards

How is the overall evaluation for the course distributed?

Test 10 %, Lab Assessments 1–3 (10 %, 15 %, 15 %), Log book 10 %, Final Exam 40 %.

5
New cards

Besides learning C syntax, what three skills does this course emphasize?

Problem solving, analytical skills, and applying C to solve problems.

6
New cards

Define an algorithm.

A step-by-step set of instructions needed to accomplish a specific task.

7
New cards

Give two common ways to write an algorithm.

Pseudocode (numbered sentences) and flow charts (visual diagrams).

8
New cards

In a flow chart, what shape represents Start/End?

The terminator symbol (rounded rectangle/oval).

9
New cards

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.

10
New cards

State the formula for the area of a triangle used in the sample task.

Area = 0.5 × base × height.

11
New cards

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.

12
New cards

Give the pseudocode (in brief) for calculating triangle area.

Read base and height; compute area = 0.5 × base × height; print area.

13
New cards

Which standard C library header is required for basic input/output?

stdio.h

14
New cards

In C, which function is typically used to read formatted input?

scanf()

15
New cards

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.

16
New cards

List the five general phases of system development.

Analysis, Design, Implementation, Testing, Deployment.

17
New cards

Name the four step cycle shown for programming with an IDE.

Coding → Compile/Build → Run → Debug.

18
New cards

Who is a programmer?

A person who writes program code and knows programming basics such as variables, loops, and selections.

19
New cards

Define a programming language.

A set of keywords and syntax rules that can be understood by a computer to create programs.

20
New cards

List any four elements of a programming language mentioned.

Keywords/Reserved words, Identifiers, Variables, Constants, Arithmetic operators, Logical operators, Comments, Syntax.

21
New cards

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.

22
New cards

Provide three examples of C keywords/reserved words.

int, if, while (others acceptable: for, double, include, main, etc.).

23
New cards

What is syntax in programming?

The exact set of rules for arranging words and symbols to form valid instructions; violating them causes syntax errors.

24
New cards

Write the basic skeleton of a minimal C program as shown in class.

include

void main() {
// all coding here
}

25
New cards

Explain what a variable is in C.

A named location in memory that can hold a value which may change during program execution.

26
New cards

Are variable names in C case-sensitive?

Yes, e.g., myNumber and mynumber are different identifiers.

27
New cards

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.

28
New cards

What is a constant?

A value that does not change during program execution; can be named (via const or #define) or unnamed (literal).

29
New cards

Show the syntax of a C block comment and a line comment.

Block: /* comment */ ; Line: // comment

30
New cards

What symbol begins every preprocessor directive?

The hash or pound symbol (#).

31
New cards

Give two common preprocessor directives and their purposes.

define to create symbolic constants; #include to insert header files.

32
New cards

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.

33
New cards

State three things a data type determines.

Type of data stored, number of bytes in memory, range of values, and allowed operations.

34
New cards

List the four data-type modifiers supported in C.

short, long, signed, unsigned.

35
New cards

What is the memory size of a standard int on the lecture slide?

32 bits / 4 bytes.

36
New cards

According to Hungarian notation, what prefix is used for a double variable?

d (e.g., dHeight).

37
New cards

Declare and initialize a named constant of type float with value 0.05.

const float fTax = 0.05;

38
New cards

List the five categories of operators introduced.

Arithmetic, Relational, Logical, Compound assignment, Bitwise.

39
New cards

Provide the arithmetic operators available in C.

  • - * / %
40
New cards

What is the modulus operator used for?

To obtain the remainder of integer division (e.g., 20 % 3 → 2).

41
New cards

What relational operator checks for inequality?

!=

42
New cards

Write the logical AND and OR operators in C.

&& (AND) and || (OR).

43
New cards

What is the outcome type of relational and logical expressions?

Boolean (true or false).

44
New cards

Complete the truth table entry: true AND false = ?

false.

45
New cards

Give the compound assignment equivalent of val = val + 1.

val += 1; (or val++;).

46
New cards

Explain the difference between prefix and postfix increment.

Prefix (++i) increments before the value is used; postfix (i++) uses the value first then increments.

47
New cards

List the highest-precedence operator group in the provided table.

Unary operators ! + - (prefix).

48
New cards

Which function is used to display formatted output in C?

printf().

49
New cards

Give the format specifier for an int and for a double.

%d for int; %lf for double.

50
New cards

What escape sequence produces a new line?

\n

51
New cards

Why must addresses be supplied to scanf?

Because scanf stores input values into the memory locations of variables, so &variable is needed.

52
New cards

Define a bug and debugging.

A bug is an error in code; debugging is the process of finding and eliminating errors.

53
New cards

List the three main types of program errors.

Compile-time errors, Run-time errors, Logical errors.

54
New cards

What kind of error is dividing by zero?

Run-time error (fatal error caused by the OS during execution).

55
New cards

Why are logical errors the hardest to detect?

Because the program runs without crashing, but produces incorrect results noticeable only upon careful checking.

56
New cards

What is a test case?

A set of inputs with predicted outputs used to verify program correctness.

57
New cards

Name the three common categories of test cases mentioned.

Functionality, Performance, Usability test cases.