Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions