C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Yes / No Questions (Q.No. 3)
3.
Will the following program work?
#include<stdio.h>

int main()
{
    int n=5;
    printf("n=%*d\n", n, n);
    return 0;
}
Yes
No
Answer: Option
Explanation:
It prints n=    5
Discussion:
22 comments Page 3 of 3.

Nandish said:   6 years ago
Here the spaces are printed in the first n and for the second n, the value has assigned. !

Kiran S P said:   5 years ago
Can anyone explain this and also interchange " printf("n=%**d\n", n, l);" and explain how it works?

#include<stdio.h>

int main()
{
int n=5,l=9;
printf("n=%**d\n", l, n);
return 0;
}


Post your comments here:

Your comments will be displayed after verification.