arrow
arrow
arrow
The output of the following C++ Program is: #include <stdio.h> int main (void) { int x, *p; x = 30; p = x; print f (
Question



The output of the following C++ Program is:
#include <stdio.h>
int main (void)
{
int x, *p;
x = 30;
p = x;
print f ("%d", *p);
return 0;
}

A.

30

B.

value of x

C.

address of x

D.

Error

Correct option is D


The program will result in an error because p = x; is incorrect. p is a pointer, and it should be assigned the address of x, not its value. The correct assignment should be p = &x;. As written, the program tries to assign an integer value to a pointer, which is invalid and will cause a compilation error.

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
353k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow