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

Write a C program that evaluates the equations provided below. All equations sho

ID: 3783222 • Letter: W

Question

Write a C program that evaluates the equations provided below. All equations should be placed in a single project! The program must prompt the user for inputs to the equations and evaluate them based on the inputs. All variables on the right hand sides of the equations must be inputted by the user. All variables, except for the plaintext_character, encoded_character, and variable a are floating-point values. The plaintext_character and encoded_character variables are characters, and the a variable is an integer. PI must be defined as a constant macro (#defined constants). Error checking is not required for your program. You do not need to check for faulty user input or dividing by zero.

Character encoding: encoded_character = (plaintext_character - 'a') + 'A' (note: what happens if plaintext_character is lowercase?)

Gauss Lens Formula (solve for f): 1 / f = 1 / u + 1 / v, where u is the object distance, v is the image distance, and f is the focal length of the lens

Tangent: tan_theta = sin (theta) / cos (theta) (recall: find the appropriate functions in <math.h>)

Resistive divider: vout = r2 / (r1 + r2) * vin

General equation: y = a / (a % 2) - (63 / -17) + x * z (recall: a is an integer; the 63 and -17 constants in the equation should be left as integers initially, but explicitly type-casted as floating-point values)

Explanation / Answer

#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979
int main()
{
   float f,u,v,theta,r1,r2,vin,x,z,y,vout,tan_theta;
   char encoded_character,plaintext_character;
   int a;
   //Character Encoding
   printf("Enter plintext caharacter: ");
   scanf("%c",&plaintext_character);
   encoded_character=(plaintext_character-'a')+'A';
   //Gauss Lens Formula
   printf("Enter u & v :");
   scanf("%f %f",&u,&v);
   f=1.0/((1.0/u)+(1.0/v));
   //Tangent
   printf("Enter the angle:");
   scanf("%f",&theta);
   tan_theta=sin((theta*PI)/180.0)/cos((theta*PI)/180.0);
   //Resistive Divider
   printf("Enter r1,r2,vin respectively:");
   scanf("%f %f %f",&r1,&r2,&vin);
   vout=(r2/(r1+r2))*vin;
   //General Equation
   printf("Enter values of a,x,z :");
   scanf("%d %f %f",&a,&x,&z);
   y=a/(a%2)-((float)(63)/(float)(-17))+x*z;
  
   //To print Outputs uncomment below line
   //printf("%c %f %f %f %f",encoded_character,f,tan_theta,vout,y);
  
}

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