What is the output of the following C program?#include <stdio.h>
int main(void) {
int x, *p;
x = 30;
p = x;
printf("%d", *p);
return 0;
}
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. Error
Explanation
p = x assigns an int to a pointer (it should be p = &x). This is a constraint violation, and dereferencing address 30 is invalid, so the result is an error.More Programming Languages and Computer Graphics questions
- Multiple inheritance is permitted directly in: A. C++ B. Java C. Python D. VB.NET E. BASIC Choose the most appropriate answer from the opti…
- Which of the following are markup languages? A. HTML B. XML C. DHTML D. LML E. PML Choose the correct answer from the options given below:
- Arrange the following in the correct order so that they follow a proper run-time environment. A. Programming statement B. Compilation C. Me…
- Match List I with List IIList I List II A. Union I. Virtual Reality B. Function II. Shadow mask C. Interactive Environment III. Subroutine…
- Which of the following algorithms are used for line drawing? A. DDA algorithm B. Bresenham algorithm C. Mid-point algorithm D. Curve algori…
- The least values of signed and unsigned 8-bit data-type variables would be: