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.
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.
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?
Vasavi said:
1 decade ago
Here 1 indicates space. Before printing result it takes one space and print the value.
Suri said:
1 decade ago
It will print the value of a after the space of whatever integer is given after %.
Sweety said:
8 years ago
Then what does "++" indicates after "%1d++\n"?
Vaishu said:
1 decade ago
If we give %0.1d means what is the output of this program?
Rahul gite said:
1 decade ago
a=3.15529.
printf("%6.2f\n",a);
This means?
printf("%6.2f\n",a);
This means?
MITHUN YADAV said:
1 decade ago
%0.1d means it will print one digit after decimal.
Payal said:
7 years ago
Please explain in detail.
Vishwambar said:
4 years ago
Thanks for explaining it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers