A QUESTION ASKED IN UGC NET EXAMINATION 25. Find the output of - TopicsExpress



          

A QUESTION ASKED IN UGC NET EXAMINATION 25. Find the output of the program: #include < iostream.h> set_val(int, int); void main( ) { int a = 20, b = 10; set_val(a++, b++); printf( “\n” %d %d , a , b); } set_val( int x, int y) { x = x + y; y = y –x; x = x- y; } (A) 10 and 20 (B) 11 and 21 (C) 20 and 40 (D) 21 and 41 Really sad !!!!. The question has following errors. (1) In order to use printf(…) you should include instead of The function set_val, since it is returning nothing , should be preceded by “void” at both the places .(forward declaration and definition in the end). (2) The control string should be used as printf(“\n %d %d” , a , b); instead of printf(“\n” %d %d , a , b); If you make all these corrections then since the variables have been passed by value , the function will not make any changes in them. The post increment operators ,however,will change the values of a and b to 21 and 11and the same will be printed sequentially. Therefore the output will be 21 and 11 which does not match with any of the options. “IS THIS OUR NATIONAL STANDARD ??” Dear Paper Setter Sir, Do you know an omission of a single semicolon ( ; ) can make an spaceship crash. Is this the way we learn computer languages in India ?
Posted on: Mon, 30 Jun 2014 10:05:03 +0000

Trending Topics



Recently Viewed Topics




© 2015