Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

This is the template: #include #define MAX_SIZE 100 main() { char my_strg[ MAX_SIZE ]; double my_number = 0.0; /********** Add your code below this line

This is the template:

#include

#define MAX_SIZE 100

main() {

char my_strg[ MAX_SIZE ]; double my_number = 0.0;

/********** Add your code below this line **********/

/********** Add your code above this line **********/

printf( "%.2f ", my_number ); }

image text in transcribed

image text in transcribed

image text in transcribed

Problem B B.1 Specification Write a C program to input a line of characters in the form of a floating-point number, convert the line of characters into an actual floating point number, and display on the standard output the floating-point number. B.2 Implementation The program is named lab4b.c. Use the given template lab4b.c and fill in your code You are given an array of characters of size MAX_SIZE where MAX_SIZE = 100. The array is named my_strg. Use getchar and a loop to read a line of characters, and store the input characters into array my_strg. The loop terminates when a new line character'n' is entered. The new line character ' ' is NOT part of the line (i.e., discard the new line character ' '). The input line contains only characters 'o' to '9' and the dot character'' in the form of a valid positive floating point number of the following format: [integer part] . [fractional part) Convert the input line of characters to a double floating-point number, which is stored in variable my number EECS 2031 Page 3 of 5 Display on the standard output the double floating-point number my_number using the printi statement as follows: printf("%.2f ", my number ); Assume that the input line of characters represents a valid floating point number of the form [integer part] - [fractional part] B.3 Sample Inputs/Outputs indigo 360 x lab4b 24.5 24.50 indigo 361 lab4b 76.2421 76.24 indigo 362 lab4b 100.0 100.00 indigo 363 $ lab4b 0.255 0.26 p. NN indigo 364 lab4b 12.9999999999 13.00 indigo 365 lab4b 1.00000000099 1.00 indigo 366 lab4b In addition, all programs should follow the following guidelines: Include the stdio.h library in the header of your .c files. Use printf to print text and outputs according to the required formats. End each output result with a new line character' '. Do not use any C library functions except getchar(), putchar(), scanf() and printf(). Assume that all inputs are valid (no error checking is required on inputs)

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_2

Step: 3

blur-text-image_3

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students explore these related Databases questions