Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
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