Figure 2.16.2: Using scanf0 to read a string. char bookTitle[50] \"\"; scanf(\"%
ID: 3586131 • Letter: F
Question
Figure 2.16.2: Using scanf0 to read a string. char bookTitle[50] ""; scanf("%s", bookTitle); // & is not used when reading a string Feedback? PARTICIPATION 2.162 scanf0 format specifiers ACTIVITY Write a statement involving scanfo 1) Read a decimal integer from the user, storing the value read in the variable filmSpeed Check Show answer 2) Read a floating point value from the user and store the result in a double variable exposureTimeSec Check Show answer 3) Read a string from the user input and store the string read in a character array named filmType. Check Show answer Feedback?Explanation / Answer
1)
int integer,filmSpeed; // variable declaration
scanf("%d",&integer); // %d is used to read the integer
filmspeed=integer; // assign integer value to filmSpeed
2)
float float_value; // variable declaration
double exposureTimesec; // variable declaration
scanf("%f",&float_value); // %f is used to read the floating point value
exposureTimesec=float_value; // assign the float value to exposureTime
3)
char value[20],filmType[20]; // variable declaration
scanf("%s",&value); // %s is used to read the strings
strncpy(filmType,value,20); // assign value to the variable filmType
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.