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

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

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

DRAVID When a structure is assigned, passed, or returned, the copying is done monolithically. This means that the copies of any pointer fields will point to the same place as the original. In other words, anything pointed to is not copied. Hence, on changing the name through e2.n it automatically changed e1.n

प्र: How would you check whether the contents of two structure variables are same or not? 1810 0

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

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

struct emp {      char n[20];       int age; }; main() {     struct emp e1 = {"Dravid", 23};    struct emp e2;    scanf ("%s %d",e2.n, & e2.age);    if( structcmp (e1,e2) ==0)         printf ("The structures are equal");    else          printf ("The structures are unequal"); } structcmp ( struct emp x, struct emp y) {      if (strcmp (x.n,y.n) ==0)            if (x.age == y.age)             return (0);             return (1); } In short, if you nee to compare two structures, you'll have to write your own function to do so which carries out the comparison field by field.

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

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

EOF has been defined as #define EOF -1 n the file "stdio.h" and an unsigned char ranges from 0 to 255 hence when EOF is read from the file it cannot be accommodated in ch. Solution is to declare ch as an int.

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

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

The last line from the file "trial" would be read twice. To avoid this, ues:        While ( fgets (str, 80, fp) ! = NULL)                puts (str);

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

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

C: \SAMPLE.EXE

प्र: If the following program (myprog) is run from the command line as  myprog 1 2 3  what would be the output? main(int argc, char *argv[]) {     int i, j = 0;     for (i = 0; i < argc ; i++)            j = j + atoi ( argv[i]);     printf ("%d", j); } 1722 0

  • 1
    123
    सही
    गलत
  • 2
    6
    सही
    गलत
  • 3
    Error
    सही
    गलत
  • 4
    "123"
    सही
    गलत
  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर : 2. "6"
व्याख्या :

Answer: B) 6 Explanation: When atoi() tries to convert argv[0] to a number it cannot do so (argv[0] being a file name) and hence returns a zero.

प्र: What would be the output of the following program ? main()  {        unsigned  int a = oxffff;         ~a;         printf ("%x", a); } 1573 0

  • 1
    ffff
    सही
    गलत
  • 2
    0000
    सही
    गलत
  • 3
    00ff
    सही
    गलत
  • 4
    None of the above
    सही
    गलत
  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर : 1. "ffff"
व्याख्या :

Answer: A) ffff Explanation:

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

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

Yes

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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