Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an ANSI-C program that reads user input strings line by line, until a line of xxx is entered. The program then outputs the inputs

Write an ANSI-C program that reads user input strings line by line, until a line of xxx is entered. The program then outputs the inputs after reordering the first 6 rows of inputs.

Assume that there are no more than 30 lines of inputs, and also assume that there are at least 6 lines of inputs. Assume that each line contains no more than 50 characters. Note: each line of input may contain spaces. use fgets(.., 50, stdin) to read in a line. Note that a trailing is also read in. use a 2D array to store the user inputs. That is, similar to lab4, define something like records[30][50] when all the inputs have been read in (indicated by xxx), exchange row 0 and row 1 in main(), and then send the array to a function exchange() to exchange some other rows. define a function void exchange(char[][50])which takes as argument an 2D array, and swaps the record in row 2 with that in row 3, and swaps row 4 with the row 5. Assuming the array has at least 6 rows. define a function void printArray(char[][50], int n)which takes as argument an 2D array, and then prints the first n rows of the records on stdout. Use this function in main to display all the rows of the array

Sample OUTPUT:

image text in transcribed

image text in transcribed

indigo 329 % a.out Enter string: this is input 0, orange is orange Enter string: this is input 1, apple is greern Enter string: this is input 2, cherry is red Enter string: this is input 3, banana is yellow Enter string: this is input 4, do you like them? Enter string: this is input 5, yes bye Enter string: this is input 6, bye Enter string: xxx

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions