0% found this document useful (0 votes)
4 views10 pages

ShortQuestionsowp P

The document provides a comprehensive overview of fundamental concepts in C programming, including structured programming, source and object code, high-level and low-level languages, and various programming constructs. It covers topics such as identifiers, keywords, operators, errors, and the printf function, along with their definitions and examples. Additionally, it discusses the importance of data types, variable initialization, and the role of comments in code.

Uploaded by

safiurrehman546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

ShortQuestionsowp P

The document provides a comprehensive overview of fundamental concepts in C programming, including structured programming, source and object code, high-level and low-level languages, and various programming constructs. It covers topics such as identifiers, keywords, operators, errors, and the printf function, along with their definitions and examples. Additionally, it discusses the importance of data types, variable initialization, and the role of comments in code.

Uploaded by

safiurrehman546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Part II Computer C Language

Short Questions Ch 8 Section


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.
2. 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.
3. What is a Computer Program? [BWP-18, GRW-19, MTN-17, SGD-21]

A program is a set of instructions that guides a computer to perform specific tasks.


4. What is Assembly Language? [BWP-18, GRW-17, LHR-17, DGK-21]

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.
5. List four commonly used HLPL. [BWP-16, RWP-15, GRW-22]

C, C++, Java, Pascal, FORTRAN


6. Define High-Level Language. [BWP-17, GRW-21, RWP-21]

High-level language is a programming language in which program instructions


are written in the form of English-like statements.
7. Who is a Programmer? [MTN-16, RWP-16, SWL-17]

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.
8. Define Low-Level Language. [BWP-17, SGD-18]

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.
9. What is a Programming Language? [GRW-19]

A programming language is a set of words, abbreviations, and symbols that allows a programmer
to convey instructions to a computer. It is a mode of communication between a user and a
computer. It is a tool for creating sets of instructions to guide the computer.
10. Define Unstructured Programming Language. [FSD-22]
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.
11. What is Machine Language? [DGK-19]

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.

12. 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.
13. Define Header Files / Library files.
These files contain the headers of standard library functions. Each header file contains the headers
of one type of functions only. The extension of the header file is “.h”.
14. What is meant by define directives or Constant Macro? [FSD-17, GRW-18, RWP-19, SGD-
21, SWL-22]

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.
15. What are Delimiters? [FSD-21, GRW-19, MTN-18, SGD-19, SWL-22]

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.
16. Define include preprocessor. [BWL-21, MTN-21,22, RWP-19, SGD-22]

The "#include" directive provides access to library functions defined in standard header files. These
instructions tell the compiler to act compiling the source program.
17. What is meant by Statement Terminator? [GRW-17, LHR-22, MTN-22]

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."
18. What is meant by Linker? [LHR-16, MTN-18, SGD-22]

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.
19. Write short cut key of compile and run (execute) a C program. [SWL-21,22]

Ctrl + F9 is the shortcut key to run (execute) the program, and Alt+F9 is the shortcut key to
compile the program
20. What are Logical Errors? [BWL-16, SGD-18]

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.

21. Define Bugs and Debugging. [DGK-17, FSD-21]

Bugs are the errors often encountered by programmers while programming.


Debugging is the process of finding and fixing errors/bugs in programming.
22. Define Runtime Errors. [DGK-18, MTN-16]

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.

Short Questions Ch 9 Section


23. Define an identifier with an example. [MTN-19]
Identifiers in a program are names used to represent the variables, constants,
functions, labels, etc. For example, printf( ), scanf( ) etc.
24. Differentiate between standard and user-defined identifiers Give an example.
[AJK-19, SGD-22]
Standard identifiers have predefined and specific meanings. These identifiers are
available in the library of C language. “clrscr”, “sqrt”, “printf”, “scanf”, are examples
of standard identifiers.
User-defined identifiers in the C programming language are created by the
programmers. These identifiers are used to represent variables, constants,
functions, labels, etc. A programmer might create a user-defined identifier like
"marks" to represent the marks of a student in a program.
25. Define keywords/reserved words with examples. [LHR-19, DGK-22]
Keywords, also known as reserved words, have special and specific meanings in
C. There are 32 keywords in C language each with a particular purpose. Keywords
are always written in lowercase. For example, int, char, if, etc.
26. Write any four legal variable names. [MLT-14, RWP-21]
Valid variable names can be: age, marks, salary, fee, pay etc.
27. Write down two rules for naming variables in C. [BWP-16, LHR-15-16]
▶ A variable name can consist of letters, digits, and the underscore character.
▶ The first character of a variable name must be an alphabet.
▶ The underscore is also a legal first character, but it is not recommended.
28. Write a statement to declare an integer variable I initialized to 1. [SWL-19]
Statement for declaring an integer type variable:
int I = -1;
29. Differentiate between declaring and defining a variable. [AJK-17, SGD-18]
Variable Declaration
Variable Definition
▶ The Variable declaration in C specifies the variable's name and data type.
▶ The variable definition allocates the memory location to store the data in the
variable.
30. What is garbage value? [MTN-18]
If a programmer does not initialize a variable, the allocated memory may contain
some useless or meaningless data. Which is called garbage value.
31. What is variable Initialization? [GRW-19, FSD-14]
Assigning a value to the variable at the time of its declaration is called initialization.
Initialization is important to avoid garbage value.
32. Differentiate between variable and constant with types.
It is the name of memory location.
It is a value.
Its value can be changed during program execution.
It remains constant during program execution.
33. How an arithmetic overflow occurs? [RWP-19]
This issue occurs when performing the operation with two very large numbers may
result in a value too large to be accurately represented. This situation is referred
to as arithmetic overflow.
34. Why is it important to assign a data type to a variable? Give example. [MTN-17]
It is important to use the correct data type to store a value in a variable according
to the need and perform appropriate operations on variables.
35. How does cancellation error occur? [SWL-17, GRW-18]
Adding a very large number to a very small number might result in unexpected
outcomes. For Example, while using float data type, adding 1970.0 and
0.0000001243 might compute as 1970.000000 on some computers, canceling out
the smaller number.
36. List any four types of integer data in C-language. [DGK-16]
int
unsigned int
long int
unsigned long
37. What happens when arithmetic underflow occurs? [LHR-16]
This issue occurs when performing operations with very small numbers, the result
may be too small to be accurately represented, so it is often represented as zero.
This situation is referred to as arithmetic underflow.
38. Define the concept of operator’s precedence. [AJK-16, FSD-15-16]
Operator precedence, also known as the hierarchy of operators, determines the
order in which operators are evaluated within an expression.
Operators
39. Which operators are used to evaluate compound conditions?[MTN-17, RWP-19]
Logical operators are symbols usually used to combine two or more relational
expressions also known as compound conditions. In C, the primary logical
operators are:
▶ Logical AND (&&)
▶ Logical OR (||)
▶ Logical NOT (!)
40. What is the use of OR operator? [FSD-16, BWP-14]
OR is a binary operator that requires two operands for evaluation. It produces true
if any expression is true, and false if all the expressions are false.
41. Define assignment statement with example. [LHR-14]
A statement using an assignment operator is called an assignment statement. In
the assignment statement, the right side value is always assigned to the left side.
42. List any four types of operators in C. [SGD-17]
▶ Arithmetic operators
▶ Relational operators
▶ Logical operators
▶ Increment / Decrement operators
43. Define increment decrement operators. [SWL-15]
++ is used as an increment operator. It is used to increase the value of the variable by 1.
-- is used as a decrement operator. It is used to decrease the value of the variable by 1.
44. What are the uses of Operators? [BWP-15, SWL-18]
Operators are symbols or signs used to perform specific tasks on data. They are
used for operations like addition, subtraction, comparison, and others.
45. Define relational operators. Enlist different types of relational operators.
[RWP-14]
Relational operators are used to compare two values, and they always evaluate to
true or false. A true state is represented by a non-zero value (1) whereas a false
state is represented by a zero value (0).
Different types of relational operators: ==, <, >, <=, >= and !=.
46. What is the use of AND logical operator? [FSD-16, SWL-15]
AND(&&) is a binary operator that requires two operands for evaluation. It
produces true if all the expressions are true, and false if any expression is false.
47. Differentiate between unary and binary operators with examples.
[AJK-14, LHR-18]
Unary Operator Binary Operator
The operator requires only one The operator requires two operands or
operand or data item to evaluate. data items to evaluate.
Example: ++, --, ! Example: +, *, /
48. Define logical operator. Give example. [SGD-16, RWP-18]
Logical operators are symbols usually used to combine two or more relational
expressions. In C, the primary logical operators are:
▶ Logical AND (&&)
▶ Logical OR (||)
▶ Logical NOT (!)
49. List the symbol of arithmetic operators. [FSD-22]
Operation Symbol
Addition +
Subtraction -
Multiplication *
Division /
Modulus (Remainder) %
50. What is an Expression? [RWP-15-22, DGK-19]
An expression is a combination of operands and operators, where operands can
be constants or variables.
51. What is an Arithmetic Expression? [BWP-15, SWL-19]
Expressions using arithmetic operators are called arithmetic expressions.
Example: x+y
4–2
a*b–c
52. Describe single line comments in C. [BWP-14, SGD-
14] Single-line comments are inserted by typing two forward slashes (//) before
the beginning of a line.
Example: //This program is used to calculate the Grades of Students.
53. How are comments added on multiple lines? [DGK-14, LHR-14]
Comments that consist of more than one line are called multi-line comments.
Multi-line comments are written between a /* and */.
Example: /*This program displays if

a given number is EVEN or ODD */


54. Why are comments used in the C program also give an example.
[LHR-22, FSD-19]
Comments are non-executable statements added by programmers to explain the
logic of code. They are not translated or executed by the compiler, so they do not
affect the program’s size or performance.
55. What is the difference between implicit and explicit type casting?
[RWP-17, DGK-16]
Implicit means the automatic conversion of one data type to another by the C
compiler. If the data types of operands are different, then the value of the lower
data type is automatically converted into a higher data type in that expression.
Explicit is specified by the programmer in the code. To perform explicit type
casting, a type cast operator is used i.e., convert one numeric data type into
another numeric data type.

Short Questions Ch 10 Section

56. What is the purpose of printf function?


[LHR-21,14, AJK-21, DGK-21, FSD-14, RWP-19]

printf function is used to display text messages and values of variables on monitor
screen in a specific format. It is also called formatted output function.
57. How printf function is used to print value of a variable? Write its syntax.
[LRH-16]

printf can also be used to display values of different variables on the output screen.
For this purpose, printf function require two parameters. It is written as:
Syntax: printf(Format string, Argument list);
58. For what purpose format string is used in printf function? [LHR-13, MLT-16]
It is also called control string. It is written in between double quotation marks. This
format string may contain simple text, format specifiers and escape sequences.
59. What are format specifiers? What is the purpose of format specifier in
input/output statements?
[AJK-18, BWP-22, DGK-15, FSD-22, GRW-21,16, RWP-22,17,14, SWL-22, SRG-21,16]

Format specifier is a special code used to specify the type and format of the data
being read or written. It specifies the data type, field width and format of the value.
It helps the computer understand how to interpret and display the values correctly.
A format specifier is written in the format string of printf and scanf statements.
60. Write general form of format specifiers. Also write an example. [SWL-1,14]
A format specifier begins with “%” symbol followed by a conversion character.
Its general form is: % conversion character.
Example: “%d” is the format specifier for integers. Here “%” is format symbol and
“d” is the conversion character that represents “int” data type.
61. Discuss the purpose of any two format specifiers. [DGK-21,GRW-18, MLT16]
“%d” format specifier is used to read or print a decimal integer value.
“%f” format specifier is used to read or print a real or floating point value.
62. Enlist the format specifiers for characters. [BWP-14] E, K
Format specifiers for characters are: %c and %s.
63. Discuss the purpose of field width specifier. Where it is written?
[BWP-14, FSD-21]

Field width specifier is a numeric code or rule that specifies the minimum number
of columns used to printf a value. It determines the space occupied by a value on
the output screen. It is written within format specifier in printf or scanf statements.
Its use is optional.
64. What is meant by escape sequence?
[LHR-14, BWP-18, FSD-14, GRW-14,13, MLT-18, RWP-18, SWL-21]

Escape sequence ae the characters that are used to control or format the output
on the output devices. These can be used anywhere within the control string of a
printf statement. An escape sequence begins with a backslash “\” followed by a
single character. Backslash “\” is called control character or escape character. The
next single character after backslash is called code character or sequence
character.
65. Enlist any five escape sequence characters. [BWP-21,16, RWP-21]
Escape sequence characters are: \n, \t, \b, \r and \f.
66. What is the purpose of scanf function? [LHR-22, FSD-16, GRW-19,15,14]The
scanf function in C is used to obtain input from the user during the executionof a
program. It allows user to store the input in one or more variables in a specific
format. scanf is also known as a formatted input statement. It can handle various
types of input data including numbers, characters and strings.
67. Why (&) sign is used before variable name in scanf statement?
[LHR-21, BWP-21, MLT-21, SRG-16, SWL-19]

& sign is called address of operator. It specifies the address of variable in which
the value is to be stored. It is written with each variable separately.
68. Differentiate between printf and scanf functions. [DGK-15, MLT-19]
printf function is used to display text messages and values of variables on monitor
screen in a specific format. It is also called formatted output function. Whereas,
the scanf function in C is used to obtain input from the user during the execution
of a program. It allows user to store the input in one or more variables in a specific
format. scanf is also known as a formatted input statement.
69. Enlist any two functions used for character input in C. [BWP-
16] C language provides functions that are specifically designed for character
input like getch and getche. These functions allow programmers to receive input
characters from the keyboard during program execution.
70. What is the purpose of getch function?
[LHR21, BWP-21, DGK-22, FSD-18, GRW-13, MLT-21, SRG-19]

getch stands for Get character. It is used to get a single character as input from
the keyboard during the execution of the program. When a character key is
passed, the entered character is not displayed on the screen. getch function is also
used to pause a program during execution.
71. What is the purpose of getch function? [DGK-15, FSD-15, RWP-14, SRG-15]
getch stands for Get Character with Echo. Echo means to show or display. It is used
to get a single character as input from the keyboard during the execution of the
program. When a character key is pressed, the entered character is echo or
displayed on the screen.
72. Differentiate between getch and getche functions.
[LHR-18, AJK-21, BWP-14, GRW-21, MLT-22, SRG-14]

The functions getch and getche are used to get a single character as input from
the keyboard during the execution of the program. In case of getch, the entered
character is not displayed on the screen. In case of getche, the entered character
is displayed on the screen.

Short Questions Ch 11 Section


71. Define sequential structure. (MTN-
15)
OR
How instructions are executed in sequence structure. (FSD-
19) In Sequence Structure, the statements are executed in the same order in which
they are written in the program. It is the default flow of the program execution, that
starts from the first instruction and all instructions are executed one by one in a
sequence.
72. What is a control structure? (SWL-18-19, BWP-17, SGD-14, FSD-15-16,
MTN-16)
OR
What is a Control structure? Briefly describe the basic control structures for
writing programs. (BWP-17, SGD-14, FSD-15-16, SWL-18-19,
MTN-16)
Control Structures are the statements used to control the flow of execution in a
program or function.
These statements enable us to group individual instructions into a single logical unit
with one entry and one exit point. Every program uses control structures to implement
the program logic. There are three types of control structures available in C:
▶ Sequence

▶ Selection

▶ Repetition

73. Define the selection statement. List two basic selection statements in C. (SGD-16)
OR

How does a selection structure select a statement to execute? (DGK-


19) Selection Structure is used for decision-making, statements in this structure
are divided into multiple blocks and only one block of statements is executed
based on a condition. It means the block of statements after the condition is
executed if the condition is true, and ignored if the condition is false. There are
two basic selection statements in C:
a. if – else
b. switch
74. Explain the if statement. (RWP-14, GRW-
14) if is a keyword in C language, that is used to execute or ignore a set of
statements after testing a condition. It is the simplest form of selection structure
that is used to perform one-way decision-making.
75. What happens if break is missed in case block?
(SGD-14, LHR-15-16, RWP-16, MTN-17, BWP-16, FSD-14, DGK-14, SWL-14, AJK-16)

If a break statement is omitted from a case, the code within a switch statement
after the true case will execute sequentially until a break statement is encountered.
76. Why a default label is used in switch statements? (DGK-16, GRW-16-19, SWL-
17) The statements under default are executed when none of the cases is matched.
Its use is optional.
77. Write three advantages of switch statement in C-Language.
(GRW-14, SWL-14, FSD-14-15)

switch statement can make code more readable, especially when dealing with
multiple conditional branches.
Compared to a series of nested if-else statements, a switch statement can be more
concise and easier to understand, particularly when there are many cases to consider.
Adding or removing cases typically requires minimal changes to the code, making
it less error-prone and more maintainable.
78. Distinguish between if-else if and switch statements.
(SWL-15, BWP-14-15, RWP-15-16, AJK-16-17, LHR-18, MTN-16-18, FSD-16)

if-else if statement switch statement


It is complicated in terms of The code is more organized and easier to
readability and implementation. read and understand.
It is slow because the computer It is fast because the computer
evaluates more than one expression. evaluates only one expression.
Adding or removing conditions Adding or removing cases requires
requires more changes to the code. minimal changes to the code.
It can handle all data types. It does not handle floating-point
numbers.
It can handle a range of values. It cannot handle a range of values.
79. Write the syntax of switch case statement. (DGK-15, MTN-
15)
switch(expression)

case label-1:

Statements;
break; case label-2:

Statements; break;

case label-3:

Statements; break;

default:

statements;

80. Define conditional operator. Write its syntax and example.


(LHR-15-16-17, DGK-14-16, GRW-16, RWP-14-22, SWL-15)

The conditional operator is used as an alternative to the if-else statement. It is used to


perform two-way decision-making.
It is also called ternary operator because it requires three operands.
Syntax
conditional_expression? true-case statement: false-case statement

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy