Computer Concept & Programming In C - Unit II - 13

Q.17. Predict the output/error of the following code:
main ( )
{
static int var = 5;
printf(“%d”, var --);
if (var)
main ( );
}                                                                   (AKTU. 2011 - 12)
Ans. Incorrect program because main ( ) function is one and only one within a programme.

Q.18. Differentiate between primary memory and secondary memory.                                                             (AKTU. 2012 - 13)
Ans. Primary memory also known as Read Write Memory (RWM) or main memory or volatile memory stores the content as long as computer system is turned on. As soon as computer system is turned off all contents of primary memory is lost. In contrast permanent memory or secondary memory retains its content even when the power of computer system is turned off.

Q.19. What do you mean by system software ?                            (AKTU. 2012 - 13)
Ans. A system software is a software which make use of computer hardware directly or indirectly to accomplish a certain task or application. Tweo examples of system software are compiler and assembler.

Q.20. What is the difference between scanf () function with %s and gets () function used in C language ?                                                                                    (AKTU. 2012 - 13)
Ans. Scanf ( ) is a standard input function of C- language and is used to input integer, characters floating point data with %d, %C and %f format specifiers. With %s scanf ( ) accepts a string and more than one string can be accepted by scanf ( ) function. gets ( ) function is specially made to accept string in a character array and it cannot input any other data. Moreover only one string can be input at a time.

Q.21. If a = 5; b = 6, then fine value of expression : ++a&b++.             (AKTU. 2012 - 13)
Ans. a = 5 or (101)2 and b = 6 or (110)2
  ++ a and b ++
Since ++ has higher precedence over and (bitwise AND) therefore first ++ a will make a = 6 and a and b will be 110 and 110 = 110 (6)
Hence the result of operation is 6 and also the value of b will be increased by 1 after this expression is evaluated and will become 7.
Conclusion 
* The result of everall expression will be 6
* The value of a will be 6 after this operation.
* The value of b will be 7 after this operation.

Q.22 If c = 8 and d = 9 then find the value of expression :
(++ c - d ++)/c--.                                                    (AKTU. 2013 - 14)   
Ans. c = 8 and d = 9.
(+ + c - d + + ) / c - -
Highest precedence is of parenthesis ( ) then (c + + c - d + +) will make c = 8 + 1 = 9 i.e., c = 9 and then the result of (+ + c - d + +) and 9 - 9 = 0 . (The value of d) will not increase because d++ is post increment. Hence the result of entire expression will be 0.