प्रश्न और उत्तर का अभ्यास करें

प्र: What is the difference between the following declarations? extern int fun(); int fun(); 1562 0

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

There is no difference except for the fact that the first one gives a hint that the function fun() is probably in another source file.

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

Error occurs because we have mixed the ANSI prototype with K & R style of function definition. When we use ANSI prototype for a function and pass a float to the function it is promoted to a double. When the function accepts this double into a float a type mismatch occurs hence the error. The remedy for this error could be to define the function as : int fun (float aa) {   .... }

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

Here we are initalising the function pointer p to the address of the function fun(). But during this initialisation the function has not been defined. Hence an error. To eliminate this error add the prototype of the fun() before declaration of p, as shown below: extern int fun();    or simply  int fun();

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

The condition in the while loop is a must.

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

Constant expression required in the second case, we cannot use j.

प्र: Rewrite the following set of statements using conditional operators. int a =1, b ; if ( a > 10 ) b = 20; 1472 0

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

int a = 1, b , dummy; a > 10 ? b = 20 : dummy =1;   Note that the following would not have worked: a > 10 ? b = 20 : ;;

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

0  0  1 That's what some of the compilers would give. But some other compiler may give a different answer. The reason is, when a single expression causes the same object to be modified and then inspected the behaviour is undefined.

प्र: What would be the output of the following program? main() {   int i=2 ;   printf ("\n%d%d", ++i, ++i ); } 1637 0

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

Output may vary from compiler to compiler. The order of evaluation of the arguments to a function call is unspecified.

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई

      त्रुटि की रिपोर्ट करें

    कृपया संदेश दर्ज करें
    त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई