C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - General Questions (Q.No. 8)
8.
To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>

float a;
double b;
scanf("%f %f", &a, &b);
scanf("%Lf %Lf", &a, &b);
scanf("%f %Lf", &a, &b);
scanf("%f %lf", &a, &b);
Answer: Option
Explanation:

To scan a float value, %f is used as format specifier.

To scan a double value, %lf is used as format specifier.

Therefore, the answer is scanf("%f %lf", &a, &b);

Discussion:
3 comments Page 1 of 1.

Aryan said:   3 years ago
Yes, the right answer is D.

Abhi said:   1 decade ago
@Srinath.

Double= %lf which is not present in any of option apart from D.

Srianth said:   1 decade ago
See guys.

Ans:A.

Reason:.

The default real numbers takes data type as"Double".

So %f=default double. Hence ans'''.

Post your comments here:

Your comments will be displayed after verification.