logo

CuriousTab

CuriousTab

Discussion


Home C Programming Strings See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        char t;
        char *p1 = "India", *p2;
        p2=p1;
        p1 = "CURIOUSTAB";
        printf("%s %s\n", p1, p2);
        return 0;
    }
    


  • Options
  • A. India CURIOUSTAB
  • B. CURIOUSTAB India
  • C. India India
  • D. CURIOUSTAB CURIOUSTAB

  • Correct Answer
  • CURIOUSTAB India 

    Explanation
    Step 1: char *p1 = "India", *p2; The variable p1 and p2 is declared as an pointer to a character value and p1 is assigned with a value "India".

    Step 2: p2=p1; The value of p1 is assigned to variable p2. So p2 contains "India".

    Step 3: p1 = "CURIOUSTAB"; The p1 is assigned with a string "CURIOUSTAB"

    Step 4: printf("%s %s\n", p1, p2); It prints the value of p1 and p2.

    Hence the output of the program is "CURIOUSTAB India".


    More questions

    • 1. Macros have a local scope.

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. If an unsigned int is 2 bytes wide then, What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          unsigned int a=0xffff;
          ~a;
          printf("%x\n", a);
          return 0;
      }
      

    • Options
    • A. ffff
    • B. 0000
    • C. 00ff
    • D. ddfd
    • Discuss
    • 3. Declare the following statement?
      "A pointer to an array of three chars".

    • Options
    • A.
      char *ptr[3]();
    • B.
      char (*ptr)*[3];
    • C.
      char (*ptr[3])();
    • D.
      char (*ptr)[3];
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          unsigned int res;
          res = (64 >>(2+1-2)) & (~(1<<2));
          printf("%d\n", res);
          return 0;
      }
      

    • Options
    • A. 32
    • B. 64
    • C. 0
    • D. 128
    • Discuss
    • 5. Union elements can be of different sizes.

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. What will be the output of the program in DOS (Compiler - Turbo C)?
      #include<stdio.h>
      double i;
      
      int main()
      {
          (int)(float)(char) i;
          printf("%d",sizeof(i));
          return 0;
      }
      

    • Options
    • A. 4
    • B. 8
    • C. 16
    • D. 22
    • Discuss
    • 7. size of union is size of the longest element in the union

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 8. Bitwise & can be used to divide a number by powers of 2

    • Options
    • A. True
    • B. False
    • Discuss
    • 9. Assuming, integer is 2 byte, What will be the output of the program?
      #include;
      
      int main()
      {
          printf("%x\n", -1>>1);
          return 0;
      }
      

    • Options
    • A. ffff
    • B. 0fff
    • C. 0000
    • D. fff0
    • Discuss
    • 10. What is the output of the program given below?
      #include<stdio.h>
      int main()
      {
          enum status { pass, fail, atkt};
          enum status stud1, stud2, stud3;
          stud1 = pass;
          stud2 = atkt;
          stud3 = fail;
          printf("%d, %d, %d\n", stud1, stud2, stud3);
          return 0;
      }
      

    • Options
    • A. 0, 1, 2
    • B. 1, 2, 3
    • C. 0, 2, 1
    • D. 1, 3, 2
    • Discuss


    Comments

    There are no comments.

Enter a new Comment