UNIT I
Define Flowchart.
A flowchart is a visual diagram that represents an algorithm or process with steps as
boxes and arrows showing their sequence.
What is a processor.
The processor (CPU) is the brain of a computer, executing instructions from software.
Define system software.
System software manages hardware and application programs, like operating systems
and utilities.
What is pseudo code.
Pseudo code is a simplified version of an algorithm using plain language.
Define Data type.
A data type defines what kind of data a variable can store (e.g., int, float, char).
What is the executable code.
Executable code consists of instructions that the CPU can directly run.
Define constant.
A constant is a value that remains unchanged during program execution.
What is variable.
A variable is a named storage location that can hold different values during execution.
Write about logical errors.
Logical errors are flaws in a program's logic that lead to incorrect results.
Write about syntax errors.
Syntax errors occur when code violates the language's rules, preventing compilation.
UNIT I
11. Define computer. Describe the two major components of a computer system.
Definition:
A computer is an electronic device that processes data to produce meaningful
information. It performs tasks according to instructions provided by software.
Major Components of a Computer System:
1. Hardware:
o The physical components of a computer, such as the processor, memory,
storage, and input/output devices.
o Examples: CPU, RAM, hard drive, keyboard, monitor.
2. Software:
o A set of instructions that the computer follows to perform specific tasks.
o Examples: Operating systems (Windows, Linux) and application software
(MS Office).
12. Explain about primary and secondary memory.
Primary Memory:
Also known as main memory or RAM.
Volatile in nature (data is lost when power is off).
Faster and directly accessible by the CPU.
Examples: RAM, cache memory.
Secondary Memory:
Non-volatile (data persists even without power).
Used for long-term storage.
Slower than primary memory.
Examples: Hard drives, SSDs, USB drives.
UNIT I
13. List and explain the various types of operating systems.
Batch OS: Executes a batch of jobs without user interaction.
Time-Sharing OS: Allows multiple users to interact with the system
simultaneously.
Distributed OS: Distributes tasks across multiple computers.
Real-Time OS: Processes tasks within a strict time limit.
Network OS: Manages devices and resources on a network.
14. Explain in brief about the following:
i. Assembler:
Converts assembly language into machine code.
Ex:
Translates ADD R1, R2 to binary.
ii. Compiler:
Convert the entire source code of a high-level language into machine code at
once.
Ex:
GCC for C.
iii. Interpreter:
Translates and executes code line by line.
Ex:
Python interpreter.
iv. Loader:
Loads machine code into memory for execution.
Ex:
Loads .exe files into RAM.
v. Linker:
Combines multiple object files into a single executable file.
Resolves external references between modules.
UNIT I
15. Write Algorithm and Draw Flow Chart for Finding Greatest among Three
Given Numbers.
Algorithm:
1. Start.
2. Input three numbers: A, B, C.
3. Compare A with B and C:
o If A > B and A > C, A is the greatest.
4. Compare B with C:
o If B > C, B is the greatest.
5. Otherwise, C is the greatest.
6. Output the greatest number.
7. End.
Flowchart: you can draw a flowchart here for above.
16. What is an algorithm? List the characteristics of an algorithm. Also provide its
advantages and disadvantages.
Definition:
An algorithm is a step-by-step procedure to solve a problem.
Characteristics:
1. Finiteness: Terminates after a finite number of steps.
2. Definiteness: Each step is clear and unambiguous.
3. Input/Output: Accepts inputs and produces outputs.
4. Effectiveness: Steps are simple and feasible.
Advantages:
1. Easy to understand and debug.
2. Language-independent.
Disadvantages:
1. May not represent complex problems easily.
2. Needs to be converted into code for execution.
UNIT I
17. Write a short note on basic data types supported by C. Illustrate with a C
program.
Basic Data Types in C:
1. int: For integers.
Ex:
int a = 10;
2. float: For decimal numbers.
Ex:
float b = 10.5;
3. char: For single characters.
Ex:
char c = 'A';
4. double: For large floating-point numbers.
Example:
double d = 20.5678;
Example Program:
#include <stdio.h>
int main( ) {
int a = 10;
float b = 10.5;
char c = 'A';
double d = 20.5678;
printf("Integer: %d\n", a);
printf("Float: %.2f\n", b);
printf("Character: %c\n", c);
printf("Double: %.4f\n", d);
return 0;
}
UNIT I
18. Write the basic structure of a C program. Explain each section briefly with a
suitable example.
Basic Structure of a C Program:
1. Preprocessor Directives:
o Instructions processed before compilation.
o Ex:
#include <stdio.h>
2. Main Function:
o Entry point of the program.
o Ex:
int main( ) {
...
...
3. Variable Declarations:
o Declare variables for use.
o Ex:
int a;
4. Statements:
o Perform operations.
o Ex:
a = 5 + 3;
5. Return Statement:
o Indicates program termination.
o Ex:
return 0;
UNIT I
Example Program:
#include <stdio.h>
int main( ) {
int num = 10;
printf("The number is: %d\n", num);
return 0;
19. Illustrate the variety of storage classes used in C with a simple program.
Storage Classes:
1. auto: Default for local variables.
2. static: Retains value between function calls.
3. extern: Declares a global variable accessible across files.
4. register: Requests fast storage in CPU registers.
Example Program:
#include <stdio.h>
int x = 10; // extern
void test( ) {
static int count = 0; // static
count++;
printf("Count: %d\n", count);
}
int main( ) {
auto int y = 5; // auto
register int z = 15; // register
test( );
test( );
return 0;
}
UNIT I
20. Explain in your own words the various steps involved in developing a program.
1. Problem Definition: Understand what the program must accomplish.
2. Algorithm Design: Develop a step-by-step solution.
3. Coding: Convert the algorithm into a programming language.
4. Compilation: Check the program for syntax errors.
5. Testing and Debugging: Identify and fix logical and runtime errors.
6. Execution: Run the program to ensure correct functionality.
7. Maintenance: Update and improve the program as required.