logo

CuriousTab

CuriousTab

Discussion


Home C Programming Declarations and Initializations See What Others Are Saying!
  • Question
  • Which of the following is not user defined data type?

    1 :
    struct book
    {
        char name[10];
        float price;
        int pages;
    };
    2 :
    long int l = 2.35;
    3 :
    enum day {Sun, Mon, Tue, Wed};


  • Options
  • A. 1
  • B. 2
  • C. 3
  • D. Both 1 and 2

  • Correct Answer


  • Explanation
    C data types classification are

    1. Primary data types
      1. int
      2. char
      3. float
      4. double
      5. void
    2. Secondary data types (or) User-defined data type
      1. Array
      2. Pointer
      3. Structure
      4. Union
      5. Enum

    So, clearly long int l = 2.35; is not User-defined data type.
    (i.e.long int l = 2.35; is the answer.)


    More questions

    • 1. What will be the output of the program (sample.c) given below if it is executed from the command line?
      cmd> sample one two three
      /* sample.c */
      #include<stdio.h>
      
      int main(int argc, char *argv[])
      {
          int i=0;
          i+=strlen(argv[1]);
          while(i>0)
          {
              printf("%c", argv[1][--i]);
          }
          return 0;
      }
      

    • Options
    • A. three two one
    • B. owt
    • C. eno
    • D. eerht
    • Discuss
    • 2. Which of the following statement is True?

    • Options
    • A. User has to explicitly define the numeric value of enumerations
    • B. User has a control over the size of enumeration variables.
    • C. Enumeration can have an effect local to the block, if desired
    • D. Enumerations have a global effect throughout the file.
    • Discuss
    • 3. Point out the error in the program?
      struct emp
      {
          int ecode;
          struct emp *e;
      };
      

    • Options
    • A. Error: in structure declaration
    • B. Linker Error
    • C. No Error
    • D. None of above
    • Discuss
    • 4. Point out the error in the program?
      #include<stdio.h>
      
      int main()
      {
          union a
          {
              int i;
              char ch[2];
          };
          union a z1 = {512};
          union a z2 = {0, 2};
          return 0;
      }
      

    • Options
    • A. Error: invalid union declaration
    • B. Error: in Initializing z2
    • C. No error
    • D. None of above
    • Discuss
    • 5. Point out the error in the program?
      struct emp
      {
          int ecode;
          struct emp e;
      };
      

    • Options
    • A. Error: in structure declaration
    • B. Linker Error
    • C. No Error
    • D. None of above
    • Discuss
    • 6. What will be the output of the program (sample.c) given below if it is executed from the command line?
      cmd> sample friday tuesday sunday
      /* sample.c */
      #include<stdio.h>
      
      int main(int argc, char *argv[])
      {
          printf("%c", **++argv);
          return 0;
      }
      

    • Options
    • A. s
    • B. f
    • C. sample
    • D. friday
    • Discuss
    • 7. What is the purpose of fflush() function.

    • Options
    • A. flushes all streams and specified streams.
    • B. flushes only specified stream.
    • C. flushes input/output buffer.
    • D. flushes file buffer.
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char far *near *ptr1;
          char far *far *ptr2;
          char far *huge *ptr3;
          printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
          return 0;
      }
      

    • Options
    • A. 4, 4, 8
    • B. 4, 4, 4
    • C. 2, 4, 4
    • D. 2, 4, 8
    • Discuss
    • 9. Nested unions are allowed

    • Options
    • A. True
    • B. False
    • Discuss
    • 10. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char huge *near *far *ptr1;
          char near *far *huge *ptr2;
          char far *huge *near *ptr3;
          printf("%d, %d, %d\n", sizeof(ptr1), sizeof(*ptr2), sizeof(**ptr3));
          return 0;
      }
      

    • Options
    • A. 4, 4, 4
    • B. 2, 4, 4
    • C. 4, 4, 2
    • D. 2, 4, 8
    • Discuss


    Comments

    Avatar
    Prakhar
    good content


Enter a new Comment