Assignment C Language
Assignment C Language
Solution: (a)
5. When we write X=10 and Y=X, which of the following memory assignment is
correct
a) X and Y will have same location and 10 will be stored.
b) X and Y will have two distinct locations and 10 will be stored in both.
c) X and Y will have same location and only X will contain value 10
d) X and Y will have two distinct locations and only X will contain value 10
Solution: (b) X=10 will create a memory location for X and 10 will be stored. After
declaring Y=X, a new memory location for Y will be created and the value of X will be
copied in Y. This both of them will contain 10.
6. If input from the user (for Read N)is 6, the output of the following algorithm will be
a) 120
b) 720
c) 5040
d) 1
Solution: (b) The flowchart finds the factorial of the number 6. Hence, the right answer is
6!=720
7. X is an integer (X=1234). The print value of Y of the algorithm below is (note: ‘%’ is
the modulo operator, which calculates the reminder and ‘/’ gives the quotient of a
division operation)
ASSIGNMENT 1 (SOLUTION)
a) 4321
b) 10
c) 4
d) 9
Solution: (b) The flow chart calculates the sum of the digits in X. So, the right answer is
1+2+3+4=10
8. The flow chart calculates the HCF of two numbers a and b (where a is greater than or
equal to b).
Which of the following conditions need to be put inside the blanks 1 and 2 to
calculate the HCF?
ASSIGNMENT 1 (SOLUTION)
a) 1. r!=0
2. a=r and b=q
b) 1. q=0
2. a=b and b=r
c) 1. r=0
2. a=q and b=r
d) 1. r=0
2. a=b and b=r
Solution: (c) Compiler helps in translating from high-level language to machine level
language
10.Computer memory which is used to store programs and data currently being
processed by CPU is
a) ROM
b) RAM
c) Cache memory
d) PROM
ASSIGNMENT 1 (SOLUTION)