Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program which prompts the user to enter a number, and then a string. Store the number inside a float variable and store
Write a C program which prompts the user to enter a number, and then a string. Store the number inside a float variable and store the string inside a char-array with size 120. Use the scanf( ) command to scan from the Terminal Window. You can assume that the user will always enter valid data. The following code can be used to create the two variables and perform the scanning: float mynum; scanf (", \&mynum); char mystr[20]; scanf ("s", \&mystref); Notice that we do not enter any prompt to the scanf( ) command like we did with the input( ) command in MATLAB. If we wish to display a prompt to the user before scanning, we must print it ourselves using the printf () command. Next, print both variables together back to the Terminal Window using the printf () command. Note that this command works just like the sprintf () and fprintf( ) commands we've studied previously. You may need to print some \ n newline characters. Below is a sample output: Enter a numeric value: 12.5 Enter a single string: banana My number is: 12.500000 My string is: banana Press any key to continue... To avoid confusing complier errors, don't forget to include the Standard Input-Output library
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started