Fundamentals of Computer 20CS11T Chapter 5
Fundamentals of Computer 20CS11T Chapter 5
1. Programming Languages: Programming languages are used to communicate with computers. Examples
include Python, Java, C++, and JavaScript. Each language has its syntax and is suited for different types of
applications.
2. Algorithms: An algorithm is a step*by*step set of instructions for solving a specific problem. Algorithms
are fundamental to programming as they determine how a task is performed.
3. Data Structures: Data structures are ways to organize and store data efficiently. Common data structures
include arrays, lists, stacks, and queues.
4. Control Structures: Control structures, such as loops and conditionals (if*else statements), determine the
flow of a program. They help in making decisions and repeating actions.
5. Variables: Variables are used to store and manipulate data in a program. They can hold various types of
information, including numbers, text, and more.
6. Functions/Methods: Functions and methods are blocks of reusable code that perform specific tasks. They
help in organizing code and making it more modular.
7. Object*Oriented Programming (OOP): OOP is a programming paradigm that uses objects and classes
to model real*world entities and their interactions. It promotes code reusability and organization.
8. Integrated Development Environments (IDEs): IDEs are software applications that provide tools for
writing, testing, and debugging code. Popular IDEs include Visual Studio, PyCharm, and Eclipse.
9. Debugging: Debugging is the process of identifying and fixing errors or "bugs" in your code. It is a critical
skill for programmers.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 73
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
10. Version Control: Version control systems like Git help programmers track changes to their code and
collaborate with others.
11. Software Development Life Cycle: Understanding the different stages of software development, such as
requirements gathering, design, coding, testing, and maintenance, is essential for creating high*quality
software.
12. Coding Best Practices: Learning and following coding best practices and style guidelines helps ensure
that your code is readable and maintainable.
13. Problem Solving: A significant part of programming involves breaking down complex problems into
smaller, more manageable parts and devising solutions for them.
14. Application Domains: Programming is used in various application domains, from web development and
mobile app development to game development, data science, and more.
15. Continuous Learning: The field of programming is constantly evolving. Staying up*to*date with the
latest technologies and programming trends is essential.
Learning computer programming is a valuable skill that opens up numerous career opportunities and allows
you to create software solutions for a wide range of problems. Whether you are interested in becoming a
professional software developer or simply want to automate tasks and solve problems with code,
understanding the fundamentals of programming is the first step on your journey.
A) Algorithm: An algorithm is a step-by-step procedure or a set of well-defined instructions for solving a specific
problem or performing a task. It provides a clear, unambiguous solution to a problem. Algorithms are
fundamental to computer science and programming. They are step-by-step sets of instructions for solving a
specific problem or performing a specific task. Here are some key characteristics of algorithms:
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 74
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
1. Input: Every algorithm takes some input, which is the data the algorithm operates on. This input can be of
various types, such as numbers, text, or complex data structures.
2. Output: An algorithm produces an output, which is the result of its execution. The output can be a single
value, a set of values, or a modification to the input data.
3. Finiteness: An algorithm must terminate after a finite number of steps. It should not run indefinitely, also
known as halting. This characteristic is essential to ensure that the algorithm can be used in practice.
4. Certainty: Each step of an algorithm must be precisely and unambiguously defined. There should be no
room for interpretation or confusion about what each step entails.
5. Effectiveness: An algorithm should be effective, meaning that it can be executed by a human or a machine
and produce the correct result. It should be practical and feasible to execute within available resources.
6. Problem Solving: Algorithms are used to solve specific problems or tasks. They encapsulate a strategy or
method for tackling these problems, whether it's sorting a list of numbers, searching for an item in a database,
or performing complex computations.
7. Time Complexity: Algorithms can be analyzed in terms of their time complexity, which measures the
amount of time they take to run based on the size of the input data. Time complexity is often expressed using
big O notation (e.g., O(n) for linear time complexity).
8. Space Complexity: Algorithms can also be analyzed in terms of their space complexity, which measures
the amount of memory or storage they require based on the size of the input data. Space complexity is similarly
expressed using big O notation (e.g., O(1) for constant space complexity).
9. Correctness: A correct algorithm is one that solves the intended problem accurately and produces the
expected output for all valid inputs.
10. Adaptability: Some algorithms are adaptable to different situations, meaning they can be applied to
similar problems with slight modifications.
Algorithms are a fundamental concept in computer science, and their design and analysis are critical for
creating efficient and effective software solutions. Different algorithms may have varying characteristics
based on the specific problem they are designed to address and the trade-offs they make between factors like
time and space complexity.
2. Process Symbol: A rectangle with rounded corners represents a process, action, or operation that occurs in
the workflow. This can include calculations, data manipulation, or any other task.
3. Decision Symbol: A diamond-shaped symbol denotes a decision point where a question is asked, and the
flow can follow different paths depending on the answer (usually a yes/no question). Lines exiting from the
decision symbol indicate the possible paths or outcomes.
4. Input/Output Symbol: A parallelogram represents input or output operations, such as data entering the
process (input) or results being produced (output).
5. Connector Symbol: A circle with a letter or number inside (e.g., A, B, 1, 2) is used to label and reference
points in the flowchart. It helps to clarify complex flows by connecting lines to the same point labeled with
the corresponding connector symbol.
6. Flow Lines/Arrows: Arrows or lines connect the symbols to show the sequence or direction of the flow. A
solid line typically indicates the main flow, while dashed lines can be used for alternative paths or loops.
7. Terminator Symbol: A rounded rectangle with the word "STOP" or "END" is used to explicitly mark the
end of the flowchart. This is often optional but can provide clarity.
8. Predefined Process Symbol: A rectangle with double lines signifies a process that is predefined in another
part of the flowchart or in a separate document.
9. Document Symbol: A rectangle with a wavy base represents a document or report within the process.
10. Delay Symbol: A rectangle with a wavy bottom is used to indicate a time delay or waiting period within
the process.
11. Loop/Preparation Symbol: A rectangle with a vertical line on the right and two arrows pointing back
indicates a loop or iterative process.
12. Data Symbol: A parallelogram with vertical lines inside it denotes data storage or a data storage element
within the process.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 76
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
13. On-Page Connector Symbol: A small circle, typically with a letter or number inside, is used to indicate a
connection to another part of the same page when the flowchart spans multiple pages.
Rules for Drawing a Flowchart
▪ It should contain only one start and one end symbol
▪ The relevant symbols must be used while drawing a flowchart
▪ The direction of arrows should be top to bottom and left to right
▪ It should be simple and drawn clearly and neatly
▪ Be consistent in using names, variables in the flow chart
▪ Use properly labeled connectors to link the portions of the flowchart on different pages
▪ The branches of decision box must be label
C) Basics:
• Variables: Variables are used to store data. They can hold various types of information, such as
numbers, text, or Boolean values.
• Data Types: Data types define the kind of data a variable can hold. Common data types include
integers, floating*point numbers, strings, and booleans.
• Operators: Operators are used to perform operations on data. Examples include arithmetic operators
o (+, *, *, /), comparison operators (>, <, ==), and logical operators (&&, ||).
• Input and Output: Programs often need to take input from users and produce output. Functions like
`input ()` and `print()` are used for this purpose.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 77
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
D) Decision Making:
• If Statements: If statements are used for making decisions in a program. They allow you to execute
specific code blocks if certain conditions are met. For example:
• Switch Statements (or Case Statements): Some programming languages support switch statements,
which allow you to select one of several code blocks to execute based on the value of a variable or
expression.
E) Iterative Constructs:
• Loops: Loops are used to execute a block of code repeatedly. Common types of loops include:
• For Loop: Used to iterate over a sequence (e.g., a list) for a specific number of times.
• While Loop: Repeats a block of code as long as a given condition is true.
• Do-While Loop: Similar to a while loop but guaranteed to run at least once, as the condition is checked
after the loop body is executed.
• Break and Continue: The `break` statement is used to exit a loop prematurely, while the `continue`
statement skips the rest of the current iteration and moves to the next. Here's a simple example in
Python that combines these concepts:
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 78
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
d) Fourth Generation (4GL): These languages are designed for specific applications, such as SQL for
database querying and report generation. They offer a higher level of abstraction and often involve
less coding.
e) Fifth Generation (5GL): These languages focus on solving complex problems through natural
language and AI. They are still evolving and not as widely used as other generations.
The use of constants helps improve code readability and maintainability because it makes the purpose of these
fixed values explicit. It also provides a central location to change these values, if necessary, without searching
for and modifying them throughout the code.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 80
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
5.3 Process of Generating a Programming Language
The process of generating a programming language involves several stages, including design, specification,
implementation, and usage. Here's an overview of these stages with examples:
1. Design Stage:
• Purpose and Goals: The first step in creating a programming language is to define the purpose and
goals of the language. What problems will it solve? What kind of programs will it support?
Example: Python was designed to be a general*purpose, high*level language suitable for tasks ranging from
web development to scientific computing.
• Paradigm Selection: Choose the programming paradigm(s) the language will support. Common
paradigms include imperative, object*oriented, functional, and declarative.
Example: Haskell was designed with a focus on the functional programming paradigm, emphasizing
immutability and pure functions.
2. Specification Stage:
• Formal Syntax and Semantics: Create a formal specification for the language, including its syntax
and semantics. This defines how programs in the language will be structured and what they will do.
Example: The Backus*Naur Form (BNF) is a notation often used to specify the syntax of programming
languages.
• Standard Library: Design and document a standard library of functions and modules to provide
essential functionality to users.
Example: C++ includes the Standard Template Library (STL), which provides a rich set of data structures and
algorithms.
3. Implementation Stage:
• Compiler or Interpreter: Develop a compiler or interpreter for the language that translates
human*readable code into machine*executable code.
Example: The GCC (GNU Compiler Collection) is a widely*used compiler for the C and C++ programming
languages.
• Runtime Environment: Create the necessary runtime environment, including memory management,
garbage collection, and other system*level features.
Example: The Java Virtual Machine (JVM) is a runtime environment for the Java programming language.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 81
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
4. Tools and Documentation:
• Development Tools: Provide development tools like integrated development environments (IDEs)
and debuggers to make it easier for programmers to write, test, and debug code.
Example: Visual Studio Code (VS Code) is a popular code editor that supports many programming languages
through extensions.
• Documentation: Produce extensive documentation, including language reference manuals, tutorials,
and examples.
Example: The Python documentation includes a comprehensive library reference and tutorials for beginners.
7. Standardization:
In some cases, programming languages are standardized to ensure compatibility and portability across
different implementations.
Example: C and C++ are standardized by the ISO (International Organization for Standardization).
The process of generating a programming language is a complex and multifaceted undertaking, involving a
combination of design, engineering, community building, and maintenance. The success of a language
depends on its ability to meet the needs of its users and adapt to changing technology and programming trends.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 82
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
Problems
(a) Write an algorithm to find area of circle. Using equation area (𝐴) = 𝜋 × 𝑟 2
Algorithm Flowchart
Step 1: Start
or
step
Step 7: stop
2. Input A, B, C
greater”.
4. Stop
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 83
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
(c) Write an algorithm to generate the following series
1,2, 4,7, 11, 16, 12, 29...
Hint:
The series 2, 4, 7, 11, 16, 22, 29…is achieved by following system.
1 + (1) = 2; 2 + (2) = 4; 4 + (3) = 7; 7 + (4) = 11; 11 + (5) = 16; 16 + (6) = 22; 22 + (7) = 29….
Algorithm Flowchart
Step-1: Start
Step-2: Input a number in variable n
Step-3: Let i=1
Step-4: If (i ≤ n), then go to step-5,
Otherwise go to step-7
Step-5: Print value of i
Step-6: i=i+i and again go to step-4
Step-7: Stop
Note: Step 6 is important; if i=i+1 we get
1 2 3 4 – – – – n Sequence.
if i=i+2 we get
1 3 5 7- – – n Sequence.
(a) Draw flowchart to accept the length of two different line segments and check whether they are equal
or unequal. Display the message accordingly.
Algorithm Flowchart
Step 1: Start
Step 5: Stop
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 84
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
(b) Draw a flow chart to accept the age of a person and check whether he/she is a child, teenager or an
adult. A person is a child if the age is less than or equal to 14. A person is a teenager if the age is
between 15 and 17. A person is an adult if he age is greater than or equal to 18.
Algorithm Flowchart
Step 1: Start
“Teenager”
Step 4: Stop
(c) Raj has to reach his college at 9.00 am. If he leaves his house before 8.00 am, he will go by walk,
otherwise he takes a bus. Draw a flow chart for this given Scenario, to output how to travel.
Algorithm Flowchart
Step 1: Start
“Go by Walk”
Step 4: Stop
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 85
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
Previous Year Question Papers
April / May 2021
SECTION*V
9. (a) Differentiate the following:
(i) Multitasking Operating System and Multiprocessing operating system.
(ii) Real time operating system and Batch processing operating system.
(b) Write an algorithm to find area of circle. Using equation area (𝐴) = 𝜋 × 𝑟 2
(c) Draw flowchart to accept the length of wo different line segments and check whether they are equal
or unequal. Display the message accordingly.
10. (a) Explain generation of programming language. Give example for each.
(b) Define variable. Specify the rules for naming a variable. Give examples.
Octo / Nov 2021
SECTION*5
9. (a) Draw the block diagram of a computer and examine the working of functional units.
(b) Draw a flow chart to accept the age of a person and check whether he/she is a child, teenager or an
adult. A person is a child if the age is less than or equal to 14. A person is a teenager if the age is
between 15 and 17. A person is an adult if he age is greater than or equal to 18.
10. (a) Define flowchart. Explain different symbols used in flowchart
(b) Write an algorithm for finding largest of 3 numbers.
April / May 2022
SECTION*5
9. (a) Differentiate b/w Bios and UEFT.
(b) Explain high level language.
(c) Raj has to reach his college at 9.00 am. If he leaves his house before 8.00 am, he will go by walk,
otherwise he takes a bus. Draw a flow chart for this given Scenario, to output how to travel.
(d) Explain different types of constants.
10. (a) Discuss the characteristics algorithms.
(b) Write an algorithm to generate the following series 1,2, 4,7, 11, 16, 12, 29...
(c) Match the applications with following OS
Sl No Application Choice Operating System
1 Air bag in car A Mobile OS
2 Weather forecasting B Hard real time
3 Banking C Soft real time
4 Android D Network OS
5 Peer to peer E Distribution OS
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 86
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally,Alanahally Post, Mysuru, Karnataka 570028
Answer: Here's the match between the applications and the corresponding operating system categories:
1. Air bag in car - B (Hard real time)
2. Weather forecasting - C (Soft real time)
3. Banking - E (Distribution OS)
4. Android - A (Mobile OS)
5. Peer to peer - D (Network OS)
Here are explanations for each of the mentioned operating system categories. These categories of operating
systems serve different purposes and are tailored to specific application requirements.
1. Mobile OS (Mobile Operating System):
Mobile operating systems are designed specifically for mobile devices, such as smartphones and tablets. They
are optimized for touch screen interfaces, support various apps, and provide features like power management
and connectivity. Examples of mobile operating systems include Android, iOS, and Windows Mobile.
2. Hard Real-Time Operating System:
Hard real-time operating systems are designed for applications that require strict and deterministic timing and
response constraints. These systems guarantee that tasks will be executed within a specified timeframe. They
are commonly used in mission-critical applications like medical devices, aerospace, and automotive systems
where timing is critical to safety and functionality.
3. Soft Real-Time Operating System:
Soft real-time operating systems also prioritize timely task execution but provide more flexibility than hard
real-time systems. They can meet timing constraints most of the time but may not guarantee it in all situations.
Soft real-time systems are used in applications where timing is important but not as critical as in hard real-
time applications. Examples include multimedia systems and some industrial control systems.
4. Network OS (Network Operating System):
A network operating system is designed to manage and support networked resources and services. These
operating systems are often used in servers and network devices to facilitate communication, data sharing, and
resource management in a networked environment. Examples of network operating systems include Windows
Server, Linux with networking features, and Novell NetWare.
5. Distribution OS (Distributed Operating System):
A distributed operating system is designed to work across multiple interconnected computers or nodes in a
network. It provides a single unified interface to manage and access resources across the network as if they
were on a single computer. Distributed operating systems are used in distributed computing environments to
enhance resource sharing, fault tolerance, and scalability.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 87