Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need to complete the code for exercise 4 and 5 The program is c for engineers us

ID: 3839347 • Letter: N

Question

Need to complete the code for exercise 4 and 5 The program is c for engineers using code blocks enters a valid six-digit number. Print number otherwise. Use single if statements "Invalid only. variable x from the keyboard. Evaluate the expression below by displaying the value the user entered and the result to the screen as fv) (value of numeratory(value of denominator). For example, if the user enters 0 for x, then the program should display "The function f(0) 4/1." Do not perform the division. Leave the result in exact form as integers. 2x 7x 4 f(x) x2 1 5) PE 02.05 (Rectangle or square) write a program that reads two integers from the keyboard into variables length and width. The program should determine ifthe dimensions produce a square or rectangle. Check the user's input for negative values and correct them if required. Use only positive values to calculate the area and perimeter of the square or rectangle. (a) a square, print to the screen Square:" and print the area and perimeter. If (b) If a rectangle, print to the screen Rectangle:" and print the area and perimeter. COP2270 by TCunnyngham

Explanation / Answer

4.

#include <stdio.h>

int main(void) {
int x, num,den;

printf("Enter a x number: ");
scanf("%d", &x);

if(x==0)
{
printf("the function f(0)=4/1 do not perform division ") ;
}
else
{
// calculates the power
num =2*pow(x, 2)-7*x+4;//calculating numerator
den=pow(x,2)+1;//calculate denominator
printf(" numertor 2 *%d^2-7*%d+4 = %d", x,x, num);
printf(" denominator %d ^ 2+1=%d",x,den);

int d=num/den;//division of numerator and denominator
printf(" f(x) = %d",d);//print result
return 0;
}
}

output :

for x=0

the function f(0)=4/1 do not perform division

for x=14

Enter a x number:
numertor 2 *14^2-7*14+4 = 298
denominator 14 ^ 2+1=197
f(x) = 1

5.

#include <stdio.h>

int main(void) {
int len,wid;

printf("Enter a len and wid number: ");
scanf("%d%d", &len,&wid);
if(len>0 && wid>0)//if length and width is positive then only it execute inner par else it return message for positive entry
{
if(len==wid)//if both no are same then it is square
{
printf(" ======square======");
int area=len*len;
printf(" area is : %d",area);
int perimeter=4*len;
printf(" perimeter is : %d",perimeter);
}
else
{
printf(" ======Rectangle======");
int area=len*wid;
printf(" area is : %d",area);
int perimeter=2*(len+wid);
printf(" perimeter is : %d",perimeter);

}
  
}
else
{
printf("Only positive values please");
}return 0;
}

output :

with length=5 and width=5

======square======
area is : 25
perimeter is : 20

with len=4 wid=5

======Rectangle======
area is : 20
perimeter is : 18

with len=0 and wid=0

Only positive values please

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote