To scan a and b given below, which of the following scanf() statement will you use?#include<stdio.h>float a;double b;
Question
To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>
float a;
double b;
Solution
The correct scanf() statement to scan a float and a double in C would be:
scanf("%f %lf", &a, &b);
Here is the step by step explanation:
- 
%fis the format specifier for float in C. So, it is used to take the input for variablea.
- 
%lfis the format specifier for double in C. So, it is used to take the input for variableb.
- 
&aand&bare the addresses of the variablesaandb. In C,scanf()requires the addresses of the variables to store the input values.
- 
There is a space between %fand%lfwhich is used to separate the input ofaandb. You can also use\n(newline),\t(tab), etc. as separators.
Similar Questions
To scan a and b given below, which of the following scanf() statement will you use? #include<stdio.h> float a; double b; in c
scanf() is a predefined function in______header file.Answer areaa) stdlib. hb) ctype. hc) stdio. hd) stdarg. H
Which of the following function used as reading data ?Options :main()print()scanf()printf()
To print out a and b given below, which of the following printf() statement will you use?float a=3.14:double b=3.14;
Which of the following function is more appropriate for reading in a multi-word string? ans. scanf() printf() gets() puts()
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.
