Question
1) Write a C program based on the output and given infor. Below: Part a) - assume that each line of input contains no space,
1) Write a C program based on the output and given infor. Below:
Part a) - assume that each line of input contains no space, and contains at most 30 characters
- define a function int isPalindrome (char []) which determines whether the input array (string) is a palindrome and for each input word, first prints it backward, and then determines if it is a palindrome, as shown in the sample output below.
- keep on reading until a word quit is read in. You can use the isQuit() function you implemented in lab2, but you are also encouraged to explore the string library function strcmp(). You can issue man strcmp to view the manual. Note that this function returns 0 (false) if the two argument strings are equal. This is the only string library function you should use. Dont use other string library functions such as strlen, strcpy. You are encouraged not to use an extra array. Just manipulate the original array.
sample output below:
hello
olleh
Is not a palindrome
323
323
Is a palindrome
Part b) program that reads inputs from the user one integer, one floating point number, and a character operator. The program does a simple calculation based on the two input numbers and the operator. The program continues until both input integer and floating point number are -1
- use scanf to read inputs (from Standard input), each of which contains an integer, a character ('+', '-' '*' or '/') and a floating point number (defined as float) separated by blanks and use printf to generate outputs representing the operation results
- define a function float fun_IF (int, char, float) which conducts arithmetic calculation based on the inputs, - define another function float fun_II (int, char, int) which conducts arithmetic calculation based on the inputs, - define another function float fun_FF (float, char, float) which conducts arithmetic calculation based on the inputs
- note that these three functions should have the same code in the body. They only differ in the arguments type and return type and pass the integer and the float number to both the three functions directly, without explicit type conversion (casting) and output is shown below:
Enter operand_1 operator operand_2 separated by blanks> 12 + 22.3024
Your input '12 + 22.302401' result in 34.302399 (fun_IF) and 34.000000 (fun_II) and 34.302399 (fun_FF)
Enter operand_1 operator operand_2 separated by blanks>12 * 2.331
Your input '12 * 2.331000' result in 27.972000 (fun_IF) and 24.000000 (fun_II) and 27.972000 (fun_FF)
Enter operand_1 operator operand_2 separated by blanks>2 / 9.18
Your input '2 / 9.180000' result in 0.217865 (fun_IF) and 0.000000 (fun_II) and 0.217865 (fun_FF)
Enter operand_1 operator operand_2 separated by blanks> -1+-1
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