aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Masters of Computer Application (C++)
  • What is the output of the following program? void main() ...
Multiple choice

What is the output of the following program? void main() { int m=10; int *p=&m; (*p)++; cout<<(*p)++; }

  1. 12

  2. 11

  3. 10

  4. Address of m

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

The pointer p points to m (value 10). (*p)++ increments m to 11. Then cout<<(*p)++ prints 11 (post-increment returns the value before incrementing). Final value of m is 12, but output is 11.

Keep practicing — related questions

  • What is the output of the following program? void main() { int z[]={5,6,7,8,9,10}; int *p; p=z; cout<<*p+1; }
  • What will be the output of the following program? void main() { int z[]={5,6,7,8,9,10}; int *p; p=z; cout<<...
  • What does the following code output? void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; af...
  • What is the output of the following program? void main(); { int a=5,b=5; cout<<a++; cout<< -> ; cout<<++a; ...
  • What will be the output of the following program? void main() { int val=1234; int* ptr=&val; printf("%d %d"...
  • What is the output of the following program? #include<iostream.h> void x(int a,int &b) { a=a+b; a=a-b; b=b-...
  • What is the output of the following program?#include void main() { int x=7,y=6,z; z=x-- -y; cout< }
  • What does the following do: void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&...
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy