0% found this document useful (0 votes)
18 views2 pages

Pointers Pseudocodes - 1

The C code initializes an integer variable 'a' to 4 and uses a pointer 'p' to point to 'a'. A while loop prints the value of 'a' while decrementing it until it reaches 0, resulting in the output '4321'. The correct answer to the output of the code is option c) 4321.

Uploaded by

anushya.himate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Pointers Pseudocodes - 1

The C code initializes an integer variable 'a' to 4 and uses a pointer 'p' to point to 'a'. A while loop prints the value of 'a' while decrementing it until it reaches 0, resulting in the output '4321'. The correct answer to the output of the code is option c) 4321.

Uploaded by

anushya.himate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

What will be the output of the following C code?

#include <stdio.h>

int main() {
int a = 4;
p = &a;
while (*p > 0)
{
printf("%d", *p);
(*p)--;
}
return 0;
}

Options:
a) 01234
b) 1234
c) 4321
d) 0

Explanation
1. Initialization: The integer variable a is initialized to 4, and a pointer p is created
to point to a.
2. While Loop: The loop continues as long as the value pointed to by p (which is
the value of a) is greater than 0. Inside the loop:
● The current value of *p (the value of a) is printed.
● The value of *p is decremented by 1.
3.
4. Execution Flow:
● The loop will print the values of a from 4 down to 1, resulting in the
output being printed in reverse order.
5.

Correct Answer: c) 4321

You might also like