0% found this document useful (0 votes)
21 views9 pages

Exam Question

flow chart quesion

Uploaded by

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

Exam Question

flow chart quesion

Uploaded by

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

Q1. a) what is flow chart? Describe different types of flow chart. Also explain the advantage of flowchart.

What are the various symbols used in flowchart?

Ans:- A flowchart is a diagram that uses symbols and arrows to show the steps, sequences, and decisions in
a process or workflow. Flowcharts are used in computer programming to show the flow of program.

Advantages of Using FLOWCHARTS:


• Communication: Flowcharts are better way of communicating the logic of a system to all concerned or
involved.
• Effective analysis: With the help of flowchart, problem can be analysed in more effective way therefore
reducing cost and wastage of time.
• Proper documentation: Program flowcharts serve as a good program documentation, which is needed for
various purposes, making things more efficient.
• Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program
development phase.
• Proper Debugging: The flowchart helps in debugging process.
• Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of
flowchart. It helps the programmer to put efforts more efficiently on that part.

Here are the five most common shapes used in a flowchart.


 Oval (Terminal symbol)
 Rectangle (Process symbol)
 Arrow (Arrow Symbol)
 Diamond (Decision symbol)
 Parallelogram (Input/Output symbol)

Q1 b) Explain each components of computer with neat block diagram. Also differentiate primary and
secondary memory.

Ans:-
Input
All the data received by the computer goes through the input unit. The input unit comprises
different devices like a mouse, keyboard, scanner, etc. In other words, each of these devices acts
as a mediator between the users and the computer.
The data that is to be processed is put through the input unit. The computer accepts the raw data
in binary form. It then processes the data and produces the desired output.

Major Functions of the Input Unit


The 3 major functions of the input unit are-
 Take the data to be processed by the user.
 Convert the given data into machine-readable form.
 And then, transmit the converted data into the main memory of the computer. The sole
purpose is to connect the user and the computer. In addition, this creates easy
communication between them.

CPU – Central Processing Unit


Central Processing Unit or the CPU, is the brain of the computer. It works the same way a human
brain works. As the brain controls all human activities, similarly the CPU controls all the tasks.
Moreover, the CPU conducts all the arithmetical and logical operations in the computer.
Now the CPU comprises of two units, namely – ALU (Arithmetic Logic Unit) and CU (Control Unit).
Both of these units work in sync. The CPU processes the data as a whole.
Let us see what particular tasks are assigned to both units.

ALU – Arithmetic Logic Unit


The Arithmetic Logic Unit is made of two terms, arithmetic and logic. There are two primary
functions that this unit performs.
1. Data is inserted through the input unit into the primary memory. Performs the basic
arithmetical operations on it, like addition, subtraction, multiplication, and division. It
performs all sorts of calculations required on the data. Then, it sends back data to the
storage.
2. The unit is also responsible for performing logical operations like AND, OR, Equal to, Less
than, etc. In addition to this, it conducts merging, sorting, and selection of the given data.

CU – Control Unit
The control unit as the name suggests is the controller of all the activities/tasks and operations. All
this is performed inside the computer.
The memory unit sends a set of instructions to the control unit. Then the control unit in turn
converts those instructions. After that these instructions are converted to control signals.

These control signals help in prioritizing and scheduling activities. Thus, the control unit
coordinates the tasks inside the computer in sync with the input and output units.

Memory Unit
All the data that has to be processed or has been processed is stored in the memory unit. The
memory unit acts as a hub of all the data. It transmits it to the required part of the computer
whenever necessary.
The memory unit works in sync with the CPU. This helps in faster accessing and processing of the
data. Thus, making tasks easier and quicker.

Types of Computer Memory


There are two types of computer memory-
Primary Memory
This type of memory cannot store a vast amount of data. Therefore, it is only used to store recent
data. The data stored in this is temporary. It can get erased once the power is switched off.
Therefore, is also called temporary memory or main memory.

RAM stands for Random Access Memory. It is an example of primary memory. This memory is
directly accessible by the CPU. It is used for reading and writing purposes. For data to be
processed, it has to be first transferred to the RAM and then to the CPU.
Secondary Memory
As explained above, the primary memory stores temporary data. Thus it cannot be accessed in
the future. For permanent storage purposes, secondary memory is used. It is also called
permanent memory or auxiliary memory. The hard disk is an example of secondary memory. Even
in a power failure data does not get erased easily.

Output
There is nothing to be amazed by what the output unit is used for. All the information sent to the
computer once processed is received by the user through the output unit. Devices like printers,
monitors, projectors, etc. all come under the output unit.
The output unit displays the data either in the form of a soft copy or a hard copy. The printer is for
the hard copy. The monitor is for the display. The output unit accepts the data in binary form from
the computer. It then converts it into a readable form for the user.
Primary memory Secondary memory

The primary memory of a computer is the Secondary memory defines to additional


main memory that is utilized to store data storage devices that are utilized to store
temporarily. data permanently.

Primary memory is temporary. Secondary memory is permanent.

Primary memory is faster than secondary Secondary memory is non-volatile, which


memory because it is directly accessible to means it retains data even when the power
the CPU. is off.

Primary memory is directly accessible by Secondary memory is not directly accessible


Processor/CPU. by the CPU.

Nature of Parts of Primary memory varies,


It’s always Non-volatile in nature.
RAM- volatile in nature. ROM- Non-volatile.

Primary memory is volatile, which means it is Since it is non-volatile, data can be retained
wiped out when the computer is turned off. in case of a power failure.
Primary memory Secondary memory

Secondary memory devices are less


Primary memory devices are more expensive
expensive when compared to primary
than secondary storage devices.
memory devices.

The memory devices used for primary The secondary memory devices are
memory are semiconductor memories. magnetic and optical memories.

It can hold data/information currently being It can hold data/information that are not
used by the processing unit. currently being used by the processing unit.

It stores a considerable amount of data and


The capacity of primary memory is usually information. The capacity of secondary
within the range of 16 to 32 GB. memory ranges from 200 GB to some
terabytes.

Primary memory is also known as Main Secondary memory is also known as


memory or Internal memory. External memory or Auxiliary memory.

It can be accessed by a data bus. It can be accessed using I/O channels.

Examples: RAM, ROM, Cache memory, Examples: Hard Disk, Floppy Disk, Magnetic
PROM, EPROM, Registers, etc. Tapes, etc.

Q2. i) step -1 variable x,y & z is defined a int


Step 2 Then x is initialize as 1, y as 2 and z as 3
Step 3 in if condition x=4 it means the value of x is initialized as 4 and the condition is true.
Step 4 z= x+y means the value of z =4+2 means z=6
Step 5 print x , y , x means the value of x is 4, y is 2 and z is 6

So it will display 426

ii) We use the ternary operator in C to run one code when the condition is true and another code
when the condition is false.

In this program b=(a==10)?5:10; is ternary operator which means if condition is true then b=5 else
b=10
So here the condition is true as the value of a is 10 so the value of b becomes 5.

The output will be 5.

iii) step 1:-The variable n is defined and initialized as 50.

Step 2:-while loop will terminate when the value of n become less than 0.

1 st term:-Inside the loop n %2 is printed so 50 %2 reminder is 0 and will display 0.


And the n/=2 means n=n/2 so the value of n will be 25.
2 nd term:- n % 2 so 25 %2 reminder is 1 and will display 1.
n/2=2 means n=n/2 so the value of n will be 12
3rd term :- n%2 so 12 %2 reminder is 0 and will display 0.
n/2=2 means n=n/2 so the value of n will be 6
4th term :- n %2 so 6%2 reminder is 0 and will display 0.
n/2=2 means n=n/2 so the value of n will be 3
5th term :- n %2 so 3 %2 reminder is 1 and will display 1.
n/2=2 means n=n/2 so the value of n will be 1
6th term :- n % 2 so 1 %2 reminder is 1 and will display 1.
n/2 =2 means n=n/2 so he value of n will be 0.

finally the loop will terminate and we will see that it had displayed the following.

Output will be:- 010011

iv) int m=9 ,n=0 , p=0 the value of m is 9 , n is 0 and p is 0.

p+=n+=m mean p=p+n and n=n+m so the values are always calculate from right to left.
Hence n=0+9 so n=9 now p=0+n so p=9
So here the values are m=9,p=9,n=9

p+=n+=m+=-p; means p=p+n , n=n+m and m=m +(-p) so m=m-p


hence m=9-9 so m=0 , n=9+0 so n=9 and p=9+9 so p=18
the final value is m=0 , n=9 , p=18

the final Output will be:-0 9 18

v) a=15 ,b=13,c=16

x and y defined as int.


x=a-3%2+c *2/4%2+b/4
as calculations are done from right to left so the expression will calculated from right as follows:-

x=15 – 1+c * 0 %2 + 13 /4
x= 14+ 0 +3
x= 17

so the output will be 17 0 ( as y have no value but displayed first from right in printf)
3 a) Explain unary, binary and ternary operators available in c. Also describe the role of precedence and
associativity with an example.

Ans:- Unary operator


Only one operand is required to perform calculation.
++(increment operator)

-- (decrement operator)
Example
a = 5;
++a;
--a;
Binary Operator
Two operands are required to perform calculation.
+, -, *, % etc.

Example
a = 5;
b = 15;
a + b;
a - b;

Ternary Operator
Three operands are required to perform calculation.
Example
(expression 1)? (expression 2): (expression 3);
a > b?printf("a"):printf("b");

It is also called as a conditional operator in c.

Operator
Precedence Description Associativity

() Parentheses (function call)

Array Subscript (Square


[]
Brackets)

1 Left-to-Right
. Dot Operator

-> Structure Pointer Operator

++ , — Postfix increment, decrement

2 ++ / — Prefix increment, decrement Right-to-Left

+/– Unary plus, minus

Logical NOT, Bitwise


!,~
complement

(type) Cast Operator


Operator
Precedence Description Associativity

* Dereference Operator

& Addressof Operator

sizeof Determine size in bytes

3 *,/,% Multiplication, division, modulus Left-to-Right

4 +/- Addition, subtraction Left-to-Right

Bitwise shift left, Bitwise shift


5 << , >> Left-to-Right
right

Relational less than, less than or


< , <=
equal to
6 Left-to-Right
Relational greater than, greater
> , >=
than or equal to

Relational is equal to, is not


7 == , != Left-to-Right
equal to

8 & Bitwise AND Left-to-Right

9 ^ Bitwise exclusive OR Left-to-Right

10 | Bitwise inclusive OR Left-to-Right

11 && Logical AND Left-to-Right

12 || Logical OR Left-to-Right

13 ?: Ternary conditional Right-to-Left

14 = Assignment Right-to-Left

+= , -= Addition, subtraction assignment

*= , /= Multiplication, division
Operator
Precedence Description Associativity

assignment

Modulus, bitwise AND


%= , &=
assignment

Bitwise exclusive, inclusive OR


^= , |=
assignment

Bitwise shift left, right


<<=, >>=
assignment

15 , comma (expression separator) Left-to-Right

Easy Trick to Remember the Operators Associtivity and Precedence: PUMA’S


REBL TAC
where, P = Postfix, U = Unary, M = Multiplicative, A = Additive, S = Shift, R =
Relational, E = Equality, B = Bitwise, L = Logical, T = Ternary, A = Assignment and C
= Comma
Operator Precedence in C
Operator precedence determines which operation is performed first in an expression
with more than one operator with different precedence.

b) Explain in details the data types , identifiers , keywords and constants of c.


Ans:- The data types in C can be classified as follows:
Types Description Data Types

Primitive data types are the most basic data types


Primitive Data int, char, float,
that are used for representing simple values such as
Types double, void
integers, float, characters, etc.

The data types that are derived from the primitive or


Derived array, pointers,
built-in datatypes are referred to as Derived Data
Types function
Types.

User Defined The user-defined data types are defined by the user structure,
Data Types himself. union, enum

Keywords are predefined, reserved words used in programming that have special
meanings to the compiler. Keywords are part of the syntax and they cannot be used as
an identifier.
C Keywords
auto double int struct

break else long switch

case enum register typedef

char extern return union

continue for signed void

do if static while

default goto sizeof volatile

const float short unsigned

Identifier refers to name given to entities such as variables, functions, structures etc.

Identifiers must be unique. They are created to give a unique name to an entity to
identify it during the execution of the program. For example:

int money;
double accountBalance;

Here, money and accountBalance are identifiers.

A constant in C is a variable that cannot be modified once it is declared in the


program. We can not make any change in the value of the constant variables after
they are defined.

We define a constant in C language using the const keyword. Also known as a const
type qualifier, the const keyword is placed at the start of the variable declaration to
declare that variable as a constant.
Syntax to Define Constant
const data_type var_name = value;

You might also like