aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Programming (C/C++)
  • What will be the output of the following function? main()...
Multiple choice

What will be the output of the following function?

main() { char *p; printf(%d %d ,sizeof(*p),sizeof(p)); }

  1. 12

  2. 22

  3. 11

  4. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The expression sizeof(*p) gives the size of a char (1 byte), while sizeof(p) gives the size of the pointer itself. In many 16-bit environments, pointers are 2 bytes, leading to the output 1 2.

Keep practicing — related questions

  • What is the output ? main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
  • What will be the output of the following function? #define int char main() { int i=65; printf(%d,sizeof(i)); }
  • What is the output of the following code snippet ?? void main() { printf("%d", sizeof(2.0)); }
  • What will be the output of the following set of code after execution? void main() { printf(“%d %d”,sizeof('...
  • What will be the output of the following program : void main() { printf("%d",sizeof(integer)); }
  • What will be the output of the following C code? void main() { char ch=321; printf(%d %c,ch,ch); }
  • What will be the output of the following function? main() { printf(%x,-1<<4); }
  • void main() { printf("%d"t, sizeof(7.5)); printf("%d"t, sizeof(80000)); printf("%d"t, sizeof('B')); }. Whic...
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy