We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
Q1) Define a programming language and explain its role in
computer programming. Explain different programming
languages.
ANS1)
Programming languages allow us to communicate with
computers through computer code. Programming
language is simply a means to tell a computer what it
should do. It’s a language your computer understands and
knows how to process.
Computer is a machine and we are human beings. Human
wants to talk to Computer. Both must know a common
language. These languages which are understandable by
both Human and Computer are called Programming
languages. C, C++, JAVA, FORTRAN, COBOL, Python etc.
are the Programming languages.
There are three major categories of computer
programming languages namely:
i! Low level (Assembly, Machine code).
¢ Low level languages (LLL) are languages which are
machine/processor dependent e.g machine code
(binary) and assembly code.
e They are mostly used to write programs which will
work on a specific processor architecture and
computer hardware.
Mid-level (C, Assembly).
¢ This is a better version of machine language whereby
instead of using raw binary sequences to writeinstructions, we use mnemonics.
¢ These mnemonics are then translated to machine
language specific to a processor architecture by an
assembler.
e Assembly code has the best of both worlds, it is fast
and can be read and understood and also
communicates with the hardware directly.
8 High level (Java, Haskell, Prolog, FORTRAN)
The HL- languages are machine independent meaning a
program written in one system can be executed on any
other system.
e These languages are human readable,
e some are close to written English e.g python and
hence easily understandable so much so that code
written by a different programmer can be changed to
perform a different task, they are also easier to debug
and maintain
e They provide a high level of abstraction from machine
languages.
Q2) Differentiate between a compiler and an interpreter.
When might you prefer one over the other?
ANS2)
> Compiler
>» Acompiler is a software tool that translates high-
level programming code written in languages like C,C++, Java into machine code or executable code.
>» Compilers create efficient and optimized machine
code, making them suitable for performance-critical
applications. Once the code is compiled, it produces a
standalone executable file that can be run on the
target platform.
» Compilers provide benefits like improved execution
speed and the ability to catch errors before runtime.
However, the compilation process can be time-
consuming, and developers need to recompile the
code after making changes.
» Interpreter:
> An interpreter is a software tool that reads and
executes high-level programming code directly, line by
line. Instead of translating the entire code before
execution, interpreters process the code in real-time.
» They interpret and execute each statement as it is
encountered, making them suitable for scripting
languages like Python, Ruby, and JavaScript.
» Interpreters offer advantages such as quicker
development cycles, dynamic typing, and ease of
debugging, as errors are caught immediately during
execution. However, interpreted code generally tends
to run slower than compiled code.When to Prefer Which:
+ Compiler: Compilers are preferred when you want to
create a executable file. They are more suitable for
larger programs or projects where execution speed is
crucial. Once compiled, the program can run faster
since it's directly in machine code.
« Interpreter: Interpreters are beneficial during
development and testing stages. They provide quicker
feedback as errors are caught and displayed one line
at a time. Interpreted languages are often used in
scripting, prototyping, or scenarios where you want
more interactive control over the program's execution
Q3) Describe the sequence, selection, and iteration
programming structures. Provide examples of each.
ANS3)
1. Sequence: In the sequence structure, statements are
placed one after the other and the execution takes
place starting from up to down.
2. Selections: In Selections structure there is a condition
and according to a condition, a decision of either
TRUE or FALSE is achieved. In the case of TRUE, one
of the two branches is explored; but in the case of
FALSE condition, the other alternative is taken.
Generally, the ‘IF-THEN’ is used to represent branch
control
3. Iteration (Loop): The Loop or Repetition allows astatement(s) to be executed repeatedly based on
certain loop condition e.g. WHILE, FOR loops
Q4)Identify the following symbols of a Flowchart
Cc)
|
oe O
1. Oval: Used to represent start and end of flowchart
2. Rectangle: Processing: Used for arithmetic operations
and data-manipulations
3. Arrows : Flow line Used to indicate the flow of logic by
connecting symbols
4. Parallelogram: Used for input and output operation
5. Diamond: Decision making. Used to represent the
operation in which there are two/three alternatives,
true and false etc.
6. Circle : Page ConnectorQ5) Define an algorithm. What are the key characteristics
of a good algorithm?
ANS) The word “algorithm” means a procedure or a
technique. Software Engineer commonly uses an
algorithm for planning and solving the problems. An
algorithm is a sequence of steps to solve a particular
problem or algorithm is an ordered set of unambiguous
steps that produces a result and terminates in a finite time.
Algorithm has the following characteristics:
+ Input: An algorithm may or may not require input
+ Output: Each algorithm is expected to produce at least
one result
+ Definiteness: Each instruction must be clear and
unambiguous.
+ Finiteness: If the instructions of an algorithm are
executed, the algorithm should terminate after finite
number of steps.@g}? Algorithen — ee
step i start. —_
step2+ Input credik score
Shep: ck credit store oo —=12isplay, lose apmaer”
step 41 flse
—
y
y
\
‘isplay "loen dented
_ ay
— [“ioe0 approves _/ _-
= - _ o
7 —_ Break
ee
aD
ayy— —
Algorithm _ _ ‘
“step tsshare :
step ei Readxy.2 —?
_ step. 3 | espe (yay ara) - ‘
Rep ee yew) flax
step Siete tayew)] (ama
step Ook te
Tt | flew.chork : = x
se
[ea