float a;
double b;
A. scanf("%f%f", &a, &b);
B. scanf("%Lf%Lf", &a, &b);
C. scanf("%f%Lf", &a, &b);
D. scanf("%f%lf", &a, &b);
views:
136answers:
2
+5
A:
You can use
scanf("%f %lf", &a, &b);
scanf type specifiers:
- c: Single character: Reads the next character. If a width different from 1 is specified, the function reads width characters and stores them in the successive locations of the array passed as argument. No null character is appended at the end.
- d: Decimal integer: Number optionally preceded with a + or - sign.
- e,E,f,g,G: Floating point: Decimal number containing a decimal point, optionally preceded by a + or - sign and optionally folowed by the e or E character and a decimal number. Two examples of valid entries are -732.103 and 7.12e4
- o: Octal integer.
- s: String of characters: This will read subsequent characters until a whitespace is found (whitespace characters are considered to be blank, newline and tab).
- u: Unsigned decimal integer.
- x,X: Hexadecimal integer.
Modifiers:
- h : short int (for d, i and n), or unsigned short int (for o, u and x)
- l : long int (for d, i and n), or unsigned long int (for o, u and x), or double (for e, f and g)
- L : long double (for e, f and g)
Source: http://www.cplusplus.com/reference/clibrary/cstdio/scanf/
chanchal1987
2010-07-19 17:40:07
this is the right answer. well done
Asha
2010-07-19 17:50:58
@Asha: If you feel this is the right answer, you should accept it. (Do yourself a favor and read the [FAQ](http://stackoverflow.com/faq). This place works so well because it has a few rules. However, this also means that, when you do not play to the rules, this place doesn't work for you.)
sbi
2010-07-19 18:03:10
You skipped the "why" part of the question, which is a bit more important than "pick D". Doing people's homework for them is great fun, but somewhat counterproductive when they're our future co-workers.
Nathon
2010-07-19 19:28:04