Question: (50pts) Write a C program Alp2.c to read from stdin as many lines of input as possible (each line can be assumed to be an

 (50pts) Write a C program Alp2.c to read from stdin as

(50pts) Write a C program Alp2.c to read from stdin as many lines of input as possible (each line can be assumed to be an integer). Do not use an infinite loop without a break and do not force the user to type a special number (e.g. O) to indicate the end of inputs. (Hint: one possible way to achieve this is to check the return value of scanf function to break out of a loop.) The program should print the square as each input number is received. A sample run can look like the following (note that number of input integers and the integers themselves can be arbitrary so do not assume there will be four input integers): [kwang@computer] [~/temp] $ ./A1p2 some integers: Enter 1 The square of 1 is 1. 2 The square of 2 is 4. -3 The square of -3 is 9. 5^Z The square of 5 is 25. If you run the program with standard input redirection, a sample run can look like the following (assuming the text file someIntegers.txt contains the four integers 1,2,-3,5 on four separate lines): [kwang@computer][~/temp] $ ./Alp2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!