
Concept explainers
This is in language C
In this assignment, you will write a C
A two-dimensional array is often used to represent a picture (or an image). For simplicity, your
program will process only black-and-white images. Each pixel in the image will be a single
char. The only legal chars are the asterisk (‘*’) which represents the color black, and the blank
space (‘ ’) which represents the color white.
Your program must read the image from stdin. The format of the input file is as follows: the
first line of the file will contain two integers followed immediately by a newline. These numbers
represent the number of rows and columns in the image, respectively. These dimensions may be
any positive int value (i.e., more than 1 digit is possible). Each succeeding line will contain one
row of the image, followed by a newline char. For example, the input might be:
5 5
* * * *
* * *
* * *
* * *
* * *
The size of the image will be at least 1x1. If the input file does not have this format, then your
program should abort and return an exit status of 1. Note that any additional chars in the input
file also constitute an invalid input file. Your C program can abort processing and return to the
command line by executing the statement:
exit(1);
Your program will need to #include <stdlib.h> in order to access the exit function.
Your program must implement the following image transformations.
invert: This transformation should change every ‘*’ into a blank character, and every blank
character into a ‘*’
flip direction: This transformation should flip the image. If the direction is either ‘H’ or
‘h’, then the image should be flipped across an imaginary vertical line down the center of the
image. This transformation is illustrated below for an image of the letter F. If the direction
is either ‘V’ or ‘V’, then the image should be flipped across an imaginary horizontal line
across the center of the image.
rotate degrees: This transformation should rotate the image clockwise the specified number of degrees. The only legal values for degrees are 90, 180 and 270.
stretch factor: This transformation should stretch the image horizontally by the given multiple.
The input image to your program must be read from the standard input (stdin), but the
transformations to the image will be specified on the command line. You will invoke the
program as follows:
$ ./a.out list-of-desired-transformations < inputFileName
The syntax for the list-of-desired-transformations is as follows:
rot – indicates a rotation, and must be followed by exactly 90, 180, or 270.
flip – indicates a flip, and must be followed by a single char, which must be V, v, H, or h
inv – indicates an inversion
stretch – indicates a stretch, and must be followed by a single integer value (such as, 2 or 15
or 345)
For example, the program might be invoked as:
$ ./a.out rot 90 flip H inv rot 180 stretch 3 flip V < inputFileName
Note that each entry on the command line is a string of a characters, such as “rot” or “90” or
“3”. You can convert a string into an integer using the C library function atoi (ascii to integer),
as shown below.
int foobar = atoi ( argv[2] );
Your program should perform each of the given transformations, in the given order, and then
output the resulting image to stdout. Do not output the image size to stdout. Do not output any
intermediate results to stdout. Do not output any other information, such as a message saying
“Your image now looks like:”
If your program successfully transforms the image, then it should return an exit status of 0.
If the command line arguments are in any way faulty, such as the spelling of the command is
incorrect, or the rot is not followed by a legal number of degrees, or the flip is not followed by a
legal direction, then your program should abort and return an exit status of 2. This exit status
will only be returned if the format of the input file is valid. Notice that it is legal for the
command line to contain zero transformations. In this case your program should simply output
the original image.

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

- In C Programming Write a main function that declares an array of 100 ints. Fill the array with random values between 1 and 100. Calculate the average of the values in the array. Output the average.arrow_forwardC++arrow_forwardWrite a C++ program that helps the user plan out their budget. It should ask the user for the most recent 5 things that they bought; it should ask for both the name for the item and its price. Then, print out the following: total money spent, average money spent per item, lowest priced item, and highest priced item. You can assume that each item has a different name and a different price. You must use at least 1 array and you must display all numbers as dollar values (exactly 2 places after the decimal) EXPECTED OUTPUT Welcome to the Budget Helper. What are the last 5 things you bought? Item 1 name: Bananas Item 1 price: 1.5 Item 2 name: Shoes Item 2 price: 45 Item 3 name: Coffee Item 3 price: 2.5 Item 4 name: Metrocard Item 4 price: 120 Item 5 name: Jacket Item 5 price: 89 The total amount you spent is $258The average price per item is $51.60The cheapest item is BananasThe most expensive item is Jacketarrow_forward
- Java Programarrow_forwardCode with comments and output screenshot is must. Thank you!arrow_forwardWrite a C program that Defines a two-dimensional array of 7 rows and 7 columns Promotes the user to fill the array with integes. Tests whether a two-dimensional array has four consecutive numbers of the same value, either horizontally, vertically, or diagonally, and displays "Pattern Found" if the array contains four consecutive numbers with the same value. Otherwise, display Pattern NOT Found. Here are some examples of the Pattern Found case 0 103161 016 86 0 1 0 10316 1 0103161 0 103161 0168601 01686 01 016 86 0 1 5621 29 5521829 5621629 9621 829 6 5 6119 1 6 5 6119 1 6 56 61 9 1 6 96119 1 1361 4 07 1561 4 0 7 1361 4 07 13914 07 33334 07 3533 4 07 36334 07 3339407arrow_forward
- I wrote this code in c programming. what this code should do is ask how many times its going to run and run that many times(this works), ask how many books there are in a place(this works), then ask the max number of pages you want to read(this works), then asks how many pages there are in a book and put that into an array(works), then sorts the array of pages(works), and then adds the number in the array until you cant which is less than or equal to the max number of pages you want to read, and puts how many books you read(does not work), and then prints out how many books you read. a sample input is 35 206 12 3 10 25 2112 3 6 10 210 319 6 6 3 8 2 12 15 13 7 sample out put should be 345 #include <stdio.h> #include <stdlib.h> void MergeSort(int values[], int start, int end); void Merge(int values[], int start, int middle, int end); void add(int pages[], int count[], long long maxPages, long long total); void Print_Array(int count[], int cases); int main(void) {…arrow_forwardIn C++ language, write a program to print "Junior" if the given array element starts with 'J' and print "Senior" if the array element starts with 's'. Print the name of the player and the message Junior" or "Senior" accordingly. string names [5] = {"J-Liam", "S-Naoh", "S-Elijah", "J-James", "S-Henry"};arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





