chap 8
chap 8
Chapter#8
Q1: What is a Structured Programming?
Structured Programming is a type of programming that generally converts large or complex
programs into more manageable and small pieces of code. These small pieces of code are usually
known as functions, modules, or sub-programs of large complex programs. It is known as
modular programming.
Q2: Differentiate between Source code and Object code.
Source Program
A computer program written in a high-level language is called a source program or source code.
The computer does not understand the source code. First, the source code is converted into
machine code, and then it is directly executed on the computer.
Object Program
An object program, also known as object code, is a computer program written in machine
language. It is created from the source code using a compiler.
Q3: What is a Computer Program?
A program is a set of instructions that guides a computer to perform specific tasks.
Q4: What is Assembly Language?
Assembly language is a programming language in which instructions are written in the form
of mnemonics.
Mnemonics are the symbols used to represent complex instructions or information in a simplified
form.
Q6: Define High-Level Language.
High-level language is a programming language in which program instructions are written in the
form of English-like statements
Q7: Who is a Programmer?
Computer programmers, also known as developers, are the individuals responsible for creating
or modifying computer programs. They use programming languages to create instructions for a
computer to execute.
Q8: Define Low-Level Language.
Low-level language is a programming language that is very close to the actual hardware of a
computer.
A low-level programming language is machine-dependent, A machine-dependent language runs
on only one type of computer.
Q9: What is a Programming Language?
Unstructured Programming is a type of programming in which the logic of a whole program is
written in a single function, module, or piece of code.
Q10: Define Unstructured Programming Language.
Unstructured Programming is a type of programming in which the logic of a whole program is
written in a single function, module, or piece of code.
Q11: What is Machine Language?
Machine language is a programming language in which instructions of the program are written in
binary codes.
Machine language is a first-generation computer language composed of 0s and 1s, that
computers can understand without any translator.
Q12: What is a Compiler?
A compiler is a program that translates high-level programming code into machine code all at
once.
If there is any error within the program, the compiler cannot proceed to translate the source code
into machine code until that error is addressed.
Q13: What are Preprocessor Directives?
Preprocessor directives or Compiler directives are the instructions given to the compiler before
the beginning of the actual program.
Preprocessor directives are special commands in C that start with a "#" symbol. They are like
instructions given to a tool called the C preprocessor which prepares your code for compilation.
Q14: Define Header Files / Library files.
These files contain the headers of standard library functions. Each header file contains the
headers of one type of function only. The extension of the header file is “.h”.
Q15: What is meant by define directives or Constant Macro?
Constant macro is a name that is replaced by a particular constant value before compilation. It is
used to assign a constant value to an identifier. The macro name cannot be changed during
program execution.
Q16: What are Delimiters?
Delimiters are the braces within the main function that represent the start and end of the
program.
The "{" shows the starting point of your code, and the "}" indicates the endpoint of the function's
code. Anything you want your program to do lies within these curly braces – those lines are the
statements that make your program work.
Q17: Define include preprocessor.
The "#include" directive provides access to library functions defined in standard header files.
These instructions tell the compiler to act compiling the source program.
Q18: What is meant by Statement Terminator?
The statement terminator in a C program is a semicolon (;); which is used at the end of each
statement. This little semicolon serves as a signal to mark the conclusion of one instruction
before moving on to the next. Without it, the compiler will get confused and, as a result, will
generate an error message, typically stating "Statement missing."
Q19: What is meant by Linker?
Linking is the process of combining the object file produced by the compiler with additional
library files. The linker combines these files, and the final machine language program is saved as
an executable file with a “.exe” extension.
Q20: Write short cut key of compile and run (execute) a C program.
Ctrl + F9 is the shortcut key to run (execute) the program, and Alt+F9 is the shortcut key to
compile the program
Q21: What are Logical Errors?
Logical errors occur when a program follows the wrong logic, leading to unintended outcomes.
Unlike syntax errors, compilers cannot detect these errors. Logical errors do not cause program
crashes but make them difficult to identify
Q22: Define Bugs and Debugging.
Bugs are the errors often encountered by programmers while programming.
Debugging is the process of finding and fixing errors/bugs in programming.
Q23: Define Runtime Errors.
Runtime errors occur when a program tries to perform an illegal operation during its execution.
These errors are detected and displayed by the computer during program execution.
Q24: What is a Syntax Error?
A syntax error is a violation of the grammar rules in a programming language. A syntax error in
C programming occurs when a program violates grammar rules.
Q25: While writing a C program, how many types of errors can occur?
Syntax Error
Logical Error
Runtime Error
Q26: Why does a machine language program execute fast?
Machine language program executes faster because it does not require translation time, as the
program is already been written in binary form that is directly understandable by computer.
Q27: What is the difference between a compiler and an interpreter?
A compiler is a program that translates high-level programming code into machine code all at
once
An interpreter is a program that translates and executes high-level programming code into
machine code line by line as the program runs.
Q28: What is meant by statement terminator?
The statement terminator in a C program is a semicolon (;); which is used at the end of each
statement.
This little semicolon serves as a signal to mark the conclusion of one instruction before moving
on to the next. Without it, the compiler will get confused and, as a result, will generate an error
message, typically stating "Statement missing." So, remember to use semicolon to keep your
code running smoothly.
Q29: Define the body of a c-program / main () function.
In C programming, the "main" function is like the starting point of the program. Every C
program must have this function; If it is missing, you will get an error from the compiler.
The part of the program containing all the statements written inside a pair of curly braces {} is
called the "body of the main function." It is where you put all the program's instructions.
Q30: Which error is most difficult to locate and why?
Unlike syntax errors, compilers cannot detect these errors. Logical errors don't cause program
crashes but make them difficult to identify. To find logical errors, you need to examine the
incorrect output of the program, which usually requires thorough testing. Examples of logical
errors include using the wrong mathematical formula, providing incorrect inputs to the program,
or arranging statements in the wrong sequence.