Starting from:

$25

CSE102 - Computer Programming  - Homework #4  - Solved

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

 

More products