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;
}
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.
Suri said:
1 decade ago
It will print the value of a after the space of whatever integer is given after %.
Sanjoy said:
1 decade ago
Why 1 is used before d?
Vasavi said:
1 decade ago
Here 1 indicates space. Before printing result it takes one space and print the value.
Vaishu said:
1 decade ago
If we give %0.1d means what is the output of this program?
MITHUN YADAV said:
1 decade ago
%0.1d means it will print one digit after decimal.
Sivasangeetha said:
1 decade ago
Why 1 is used before d?
Rahul gite said:
1 decade ago
a=3.15529.
printf("%6.2f\n",a);
This means?
printf("%6.2f\n",a);
This means?
Muni said:
9 years ago
@Rahul Gite.
3.15.
Six spaces before it and two values after the decimal. Am I correct?
3.15.
Six spaces before it and two values after the decimal. Am I correct?
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.
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.
Sweety said:
8 years ago
Then what does "++" indicates after "%1d++\n"?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers