C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Find Output of Program (Q.No. 11)
11.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int a=250;
    printf("%1d\n", a);
    return 0;
}
1250
2
50
250
Answer: Option
Explanation:

int a=250; The variable a is declared as an integer type and initialized to value 250.

printf("%1d\n", a); It prints the value of variable a.

Hence the output of the program is 250.

Discussion:
12 comments Page 1 of 2.

Vishwambar said:   4 years ago
Thanks for explaining it.

Payal said:   7 years ago
Please explain in detail.

Sweety said:   8 years ago
Then what does "++" indicates after "%1d++\n"?

DarkoGH said:   9 years ago
You are right @Vasavi.

1 in front of %d is to allow for space.

Example %2d will give you two horizontal tab or two spaces before printing the next integer.

Muni said:   9 years ago
@Rahul Gite.

3.15.

Six spaces before it and two values after the decimal. Am I correct?

Rahul gite said:   1 decade ago
a=3.15529.

printf("%6.2f\n",a);

This means?

Sivasangeetha said:   1 decade ago
Why 1 is used before d?

MITHUN YADAV said:   1 decade ago
%0.1d means it will print one digit after decimal.

Vaishu said:   1 decade ago
If we give %0.1d means what is the output of this program?

Vasavi said:   1 decade ago
Here 1 indicates space. Before printing result it takes one space and print the value.


Post your comments here:

Your comments will be displayed after verification.