Question: C language Instruction: Write a program printsqr to print squares of integer numbers or a list of string after the printsql command. You are allowed
C language
Instruction:
Write a program printsqr to print squares of integer numbers or a list of string after the printsql command. You are allowed to enter 4 - 5 numbers or 4-5 strings. You have to use command line arguments to describe the integer numbers or string. The argument after the command is to determine what type of data for print. 'i' is for integers and 's' is for strings printing.
1: You have to use strtol() function to convert a string to a long integer for the number printing. (see Note below.)
Sample instances,
>printsqr i 3 5 6 7
>9 25 36 49
>printsqr s abc def ghi
>Error: You need to enter 4 or 5 numbers.
>printsqr s abc def ghi aaa
>abc def ghi aaa
Things to submit:
1. The source code of a c file
2. Screenshots (20%) that show successful execution of the testing cases, such as 1. invalid input; input with invalid numeric data, 2. wrong usage (not enough arguments), 3. valid input for four integers and five integers.
3. You need to use a command-line argument method. (30%)
4. format error checking and input validation are required. (10%)
5. Follow the coding format as the above posting.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
