C Programming - Input / Output - Discussion
Discussion Forum : Input / Output - General Questions (Q.No. 5)
5.
To print out a and b given below, which of the following printf() statement will you use?
#include<stdio.h>
float a=3.14;
double b=3.14;
Answer: Option
Explanation:
To print a float value, %f is used as format specifier.
To print a double value, %lf is used as format specifier.
Therefore, the answer is printf("%f %lf", a, b);
Discussion:
8 comments Page 1 of 1.
Poorvi said:
7 years ago
#include<stdio.h>
void main()
{
printf("%X%x%ci%x",11,10,'s',12);
}
Can somebody explain how the Output is Basic?
void main()
{
printf("%X%x%ci%x",11,10,'s',12);
}
Can somebody explain how the Output is Basic?
MADHU said:
8 years ago
How to create a text file to store date of birth with a specific format in C.
Nasu said:
1 decade ago
What is the use of %2c and %4c?
(1)
Vinayaka said:
1 decade ago
Please anyone tell why during for statements we use x-1 (such type) in c programs.
(1)
Burle said:
1 decade ago
Reason of output is unknown in c program
float x=5897297.3333;
printf("%7.2f",x);
output:
5897297.50
float x=5897297.3333;
printf("%7.2f",x);
output:
5897297.50
(1)
Sushant said:
1 decade ago
@Yuvraj. Try this:
#include<stdio.h>
int main()
{
int x, y, z;
for(x = 1; x <= 4; x++)
{
for(z=4-x; z > 0; z--)
{
printf("%2c",' ');
}
for(y = 0; y < x; y++)
{
printf("%4c",'*');
}
printf("\n");
}
return 0;
}
#include<stdio.h>
int main()
{
int x, y, z;
for(x = 1; x <= 4; x++)
{
for(z=4-x; z > 0; z--)
{
printf("%2c",' ');
}
for(y = 0; y < x; y++)
{
printf("%4c",'*');
}
printf("\n");
}
return 0;
}
(1)
Sankar said:
1 decade ago
Hi Yuvraj, try this code
int ix, iy;
for(ix = 1; ix <= 4; ix++)
{
for(iy = 0; iy < ix; iy++)
{
printf("*");
}
printf("\n");
}
int ix, iy;
for(ix = 1; ix <= 4; ix++)
{
for(iy = 0; iy < ix; iy++)
{
printf("*");
}
printf("\n");
}
Yuvraj said:
1 decade ago
Please tell me the program code for the output as given below.
*
* *
* * *
* * * *
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers