Question: How would you write pgminfo.cpp? Program #1: Pgminfo Your first PGM program should take a PGM file on standard input and report the number of

How would you write pgminfo.cpp?
Program #1: Pgminfo Your first PGM program should take a PGM file on standard input and report the number of rows, the number of columns, the total number of pixels, and the average value of all the pixels, padded to three decimal places. Your program should work on all valid PGM files, and should print out an error (using cerr) on any invalid PGM file. Examples of invalid PGM files are: Those that don't begin with P2. Those that don't have non-negative integers after the P2. Those that don't have the number 255 after the number of rows and columns. Those that contain the wrong number of pixels after the P2. This includes having too many pixels. Those that contain pixels whose values are not numbers between 0 and 255. Program #1: Pgminfo Your first PGM program should take a PGM file on standard input and report the number of rows, the number of columns, the total number of pixels, and the average value of all the pixels, padded to three decimal places. Your program should work on all valid PGM files, and should print out an error (using cerr) on any invalid PGM file. Examples of invalid PGM files are: Those that don't begin with P2. Those that don't have non-negative integers after the P2. Those that don't have the number 255 after the number of rows and columns. Those that contain the wrong number of pixels after the P2. This includes having too many pixels. Those that contain pixels whose values are not numbers between 0 and 255
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
