Starting from:
$35

$29

Computer Programming Homework #4 Solution

Homework Description: You will write a C file with the main function with three additional functions described below. Your program will start calling part 1, part 2 and part 3 functions in that order. For each part, you will receive the inputs from the user and print the output to the console. Details of the parts are further discussed below. Please pay attention to the output format. Any deviation from the shared format may be penalized regardless of the correct execution.

Part 1. Your function will read X floats as coefficients of an Nth order polynomial from the command prompt and writes the polynomial in a pretty format. No sign replications should be allowed. “0” can be entered as input, but it should not be shown in the output.
  (  ) =    +    −1    −1 + ⋯ + 1  +  0

Example 1:

Enter your polynomial [n a_n a_n-1 a_n-2 ... a_0]: 2 1 -3 -4

p(x) = x^2 - 3x – 4

Example 2:

Enter your polynomial [n a_n a_n-1 a_n-2 ... a_0]: 3 1 0 1 2

p(x) = x^3 + x + 2


Part 2.

Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

153 = (1*1*1)+(5*5*5)+(3*3*3)
(1*1*1)=1 - (5*5*5)=125 - (3*3*3)=27
So: 1+125+27=153

Palindrome number is a number that is same after reverse. For example 121, 34543, 343, 131, 48984 are the palindrome numbers.

Your function will read an integer from the command prompt and check if that integer is a palindrome number or an armstrong number or both.


Example 1:

Please enter an integer number : 370
Output > This number is only Armstrong number.

Example 2:

Please enter an integer number : 343
Output > This number is only Palindrome number.

Example 3:

Please enter an integer number : ???
Output > This number is both Palindrome and Armstrong number.

Example 4:

Please enter an integer number : 159
Output > This number does not satisfy any special cases


Part 3. Your function will read 2 integers from the command prompt, find the prime numbers between these integers and print their sum on the screen.

Example 1:

Please enter first integer number : 26
Please enter second integer number : 58
Output > Sum of prime numbers between 26 and 58 : 281

Example 2:

Please enter first integer number : 17
Please enter second integer number : 91
Output > Sum of prime numbers between 17 and 91 : 905

General Rules:

    1. Obey and do not break the function prototypes that are shown on each part, otherwise, you will get zero from the related part.

    2. The program must be developed on Linux based OS and must be compiled with GCC compiler, any problem which rises due to using another OS or compiler won’t be tolerated.

    3. Note that if any part of your program is not working as expected, then you can get zero from the related part, even it’s working in some way.

    4. You can ask any question about the homework by using the forum in the Teams page of the course.

More products