UG BCA S1, Fundamentals of programming using C, Second Internal Examination, November 2024
Section-A
Answer
all questions10*2=20 Marks)
Section A: Short Answer Questions
1. Define algorithm:
An algorithm is a step-by-step procedure or set of instructions designed to
perform a specific task or solve a problem.
2. Compare compiler and interpreter:
A compiler translates the entire program into machine code before execution,
while an interpreter translates the program line by line during execution.
3. Give an example of one syntax error:
Missing a semicolon (;) at the end of a statement in C:
printf("Hello, World") // Missing
semicolon
4. What is a token?
A token is the smallest unit in a program, such as keywords, operators,
identifiers, constants, and punctuation marks.
5. What is printf and scanf in C?
printf is used for output to display text, while scanf is used for input to
read data from the user.
6. What is a keyword in C?
A keyword is a reserved word in C that has a special meaning and cannot be used
as an identifier. Examples include int, return, if.
7. Explain simple if statement:
A simple if statement checks a condition and executes a block of code if the
condition is true.
if (condition) {
//
code to execute if condition is true
}
8. Compare entry-controlled and exit-controlled
loops in C:
An entry-controlled loop (e.g., for, while) checks the condition before
executing the loop body. An exit-controlled loop (e.g., do-while) checks the
condition after executing the loop body at least once.
9. What is an array in C?
An array is a collection of elements of the same data type stored in contiguous
memory locations..Give an example
10. What is getchar() in C?
getchar() is a standard library function in C used to read a single character
from the standard input (keyboard).
Section B: Short Answer Questions
11. Explain flowchart and its symbols:
A flowchart is a diagram that represents the sequence of steps in a process.
Symbols include ovals for start/end, rectangles for processes, diamonds for
decisions, and arrows for flow direction.
Each one should be represented.
12. Explain the different types of computer
languages:
o Machine Language: The lowest level of language consisting of
binary code.
o Assembly Language: A low-level language using mnemonics.
o High-Level Language: Languages like C, Python, which are easier
for humans to read.
o Fourth-Generation Languages (4GL): Languages closer to human language, like
SQL.
13. Explain C character set:
The character set in C includes alphabets (A-Z, a-z), digits (0-9), special
characters (like +, -, *, etc.), and whitespace characters (like spaces and
tabs).
14. Explain data types in C:
C data types include:
o Primary Data Types: int, float, char, double.
o Derived Data Types: Arrays, pointers.
o User-Defined Data Types: Structures, unions, enums.Give example
15. Explain the different control statements in
C:
o Decision-Making Statements: if, if-else, switch.
o Looping Statements: for, while, do-while.
o Jump Statements: break, continue, goto.Give Example
16. Explain the switch statement in C with an
example:
The switch statement selects one of many code blocks to be executed.
Copy code
int num = 2;
switch (num) {
case 1: printf("One"); break;
case 2: printf("Two"); break;
default: printf("Not One or Two");
}
17.Explain
one dimensional Arrays in C:
In C, a one-dimensional array is a collection of elements of the same
data type stored in contiguous memory locations. Each element in the array can
be accessed by an index, which represents its position within the array. Here's
a breakdown of how one-dimensional arrays work in C:
Declaring a One-Dimensional Array
To
declare a one-dimensional array in C, you specify the data type, the name of
the array, and the number of elements in square brackets.
Initializing a One-Dimensional Array
You can
initialize an array when you declare it by providing a comma-separated list of
values in curly braces {}.
If you
initialize fewer elements than the specified size, the remaining elements are
set to zero by default.
Example Program
Section C: Essay Questions
18. Explain the problem-solving life cycle in C:
The problem-solving life cycle in C includes:
o Problem Definition: Understanding the problem requirements.
o Algorithm Development: Creating a step-by-step approach.
o Coding: Writing the code in C.
o Testing and Debugging: Ensuring the code runs correctly.
o Documentation and Maintenance: Writing documentation and making updates as
needed.
19. Explain operators in C:
Operators in C are symbols that perform operations on variables and values:
o Arithmetic Operators: +, -, *, /, %.
o Relational Operators: ==, !=, >, <, >=, <=.
o Logical Operators: &&, ||, !.
o Assignment Operators: =, +=, -=, etc.
o Increment/Decrement Operators: ++, --.
o Bitwise Operators: &, |, ^, ~, <<, >>.
o Conditional (Ternary) Operator: ? :.
20. Explain looping statements in C:
Looping statements in C are used for repeating code:
o for loop: Used when the number of iterations is known.
o while loop: Repeats code as long as a condition is true.
o do-while loop: Executes the loop body at least once before
checking the condition at the end.
Comments
Post a Comment