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
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
To scan the variables 'a' and 'b' in C, you would use the following scanf() statement:
scanf("%f %lf", &a, &b);
Here is the step by step explanation:
-
%f
is the format specifier for a float in C. This is used to scan the variable 'a'. -
%lf
is the format specifier for a double in C. This is used to scan the variable 'b'. -
&a
and&b
are the addresses of the variables 'a' and 'b'. Thescanf()
function needs the addresses of the variables in order to change their values. -
The variables are separated by a space in the
scanf()
function, which means that the input should also be separated by a space.
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.