Examveda

Find the output of the following program.
void main()
{
   char *msg = "hi";
   printf(msg);
}

A. hi

B. h

C. hi followed by garbage value

D. Error

E. Garbage Value

Answer: Option A


This Question Belongs to C Program >> Pointer

Join The Discussion

Comments (5)

  1. Magdy Nasr
    Magdy Nasr:
    2 years ago

    it gives the address of h

  2. Vaishnavi Boje
    Vaishnavi Boje:
    5 years ago

    But it does not provide %d or %u so it should be error

  3. Vaishnavi Boje
    Vaishnavi Boje:
    5 years ago

    But it does not provide %d or %u

  4. Rahul Yadav
    Rahul Yadav:
    8 years ago

    how is possible if msg is a pointer so it should be a garbage value

  5. Mayank Sharma
    Mayank Sharma:
    8 years ago

    Ca anybody explain thi

Related Questions on Pointer