Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an ANSI-C program that reads user information from the standard inputs, and outputs both the original and the modified version of the records. code
Write an ANSI-C program that reads user information from the standard inputs, and outputs both the original and the modified version of the records.
code to get started with
#include #include #include #include #define ROWS 20 #define COLUMNS 30 int main(int argc, char *argv[]) { char inputs_table [ROWS][COLUMNS]; char name[10]; char ageS[10]; char rateS[10]; printf("Enter name age and rate: "); scanf("%s %s %s", name, ageS, rateS); while (....) { ..... /* read again using scanf(%s %s %s) */ } printf(" Records generated in %s on %s %s ", __FILE__, __DATE__, __TIME__); /* now display the input_table row by row */ ...... ...... return 0; }
thanks plz contact for any further questions .
8.2 Implementation A file lab4table1.c is for you to get started. The program should: use a table-like 2-D array (i.e., an array of 'strings') to record the inputs. use loop and scanf("%s %s %s") to read inputs (from standard in), one input per line, about the user information in the form of name age rate, where name is a word (with no space), age is an integer literal, and rate is a floating point literal. See sample input below. store each input string into the current available 'row' of the 2D array, starting from row 0. create a modified string of the input, and store it in the next row of the 2D array. In the modified version of input, all letters in name are capitalized, age becomes age + 10, and rate has 50% increases and is formatted with 2 digits after decimal point. Hint: for converting name to upper cases, you might need a small loop to convert character by character. continue reading input, until a name xxx is entered, followed by any age and rate values. after reading all the inputs, output the 2-D array row by row, displaying each original input followed by the modified version of the input. display the current date and time and program name before generating the output, using predefined macros such as __FILE__TIME_ (implemented for you). Note that as the partial implementation shows, each input line is read in as three 'strings' using scanf("%s %s %s", ...). In the next question, you will practice reading in the whole line as a string, as in lab4C (and then tokenize the string). Each approach has its pros and cons. Note that you will lose all marks if, instead of a 2D-array, you use 3 parallel 1-D arrays -- one of names, one of ages, one for wages -- to store and display information. 7 2020 13:32:48 8.3 Sample Inputs/Outputs: red 307 $ a.out Enter name, age and rate: john 60 1.0 Enter name, age and rate: eric 30 1.3 Enter name, age and rate: lisa 22 2.2 Enter name, age and rate: Judy 40 3.2254 Enter name, age and rate: xxx 2 2 Records generated in lab4 table1.c on Feb row [0] : john 60 1.0 row [1] : JOHN 70 1.50 row [2] : eric 30 1.3 row [3] : ERIC 40 1.95 row [4] : lisa 22 2.2 row [5]: LISA 32 3.30 row [6] : Judy 40 3.2254 row [7] : JUDY 50 4.84 red 308 %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