1. Write two small c programs. 1). The first program \"pre.c\" should read in a
ID: 3752619 • Letter: 1
Question
1. Write two small c programs. 1). The first program "pre.c" should read in a list of U.S. states and their populations. You can google to find the information. To be simple, you can use the abbreviation for each state. We assume there are at most 10 states in the list. Enter the input through the keyboard and display the output on the screen. The input ends when an EOF is encountered. The output of the program should display the states whose population is above 10 million. For example, the following are the inputs to "pre.c". The unit is million. TX 26 NC 9 MD 5 NY 19 CA 38 Ctrl-D (to terminate the input.) then "pre.c" produces the output: TX NY CA Note: an EOF is usually 'sent' to a process by hitting a CTRL_D. If you type stty -an on your unix command line, you can get info that tells you which keyboard keys mean what. FYI, in c, to put values to standard_out use printf(). To get values from standard_in use scanf() or getchar(). 2). The second program "sort.c" reads in a list of state abbreviations from stdin and display them in alphabetical order on the screen. Assume there are no more than 10 states and the sequence is read until an EOF is encountered. If the inputs are: TX NY CA The outputs should be: CA NY TX
Explanation / Answer
please find the code above. The code may not be the exact fit for both of your answers but will surely give you an idea on how i am doing the things here. For any doubts, please comment and i will clear the doubts.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.