tags:

views:

136

answers:

2
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);
+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
this is the right answer. well done
Asha
@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
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