Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi, I am tring to write a C program that can run for a select case and for loop. what I need is to let

hi, I am tring to write a C program that can run for a select case and for loop.

what I need is to let user enter the start point and end point and the function f(x), the point needed n, so I can get distance beween each dot is d=(b-a)/(n-1) to get new x,y point

and then do the select case to run 3 different case ,like shift , reflection and rotate. I have equation for each of them.

QUESTION is when i try to complie the program, the select case did not work , could you help me found which part is wrong?

image text in transcribed

==================here is the program I wrote===================================

#include #include

int main() { // First, take user input for startpoint a and endpoint b int a, b; printf(" Enter the values of startpoint a and endpoint b: "); scanf("%d %d", &a, &b); // take user input for n int n; printf(" How many points do you want to involve: "); scanf("%d", &n); // now calculate the distance float d = 1.0*(b-a)/(n-1); // now enter the equation y=f(x). A sample equation f(x) is given as a1*x^2 + a2*x^1 + a3. // first enter the power of equation f(x) int power; printf(" Enter the maximum power of equation y=f(x): "); scanf("%d", &power); // declare an array to store the coefficients of each power of x. int coeff[power + 1];

for(int i=0; i=1; i--) { printf("%dx^%d + ", coeff[i], i); } printf("%d ", coeff[0]);// lets initialize the starting point float x = 0.0; float y = 0.0;

// if user want to do shift ,then need to enter k,t .if it is shift to the up/down ,then the k=0 and t/=0;if it is shift right/left,then the k=0 and t/=0); float k,t; //if user want to reflection,then need to enter the slope M of the line float m; //if user want to rotate,then need to enter the angle float deg; char op; //start the switch for which case the user want to do switch(op) { case'shift': printf("please enter the number and unit you want to shift k,t:"); scanf("%d %d ",&k ,&t); // Now, we will run a loop to print all the coordinates (x, y) where x belongs to [a, b] for(int i=1; i

case'reflection': printf("please enter the slope m of the line go through the origin:"); scanf("%d",&m); for(int i=1; i

case'rotate': printf("please enter the angle(counterclockwise) about the origin:"); scanf("%d",°); for(int i=1; i

return 0; }

case '1" shift Knew = Xold tk Y new - Kod + + (ase " Relection Xnew = (1-m)(1+n)Xold+ 2m lol Mis the regiertim slope thogh Origm Ynew = 2m Xold - blod. + m2 lt m2 (ase "; " Potate Xnean z XolOs 4 - Yord Sno- Osthe orgle ke Yolande Ynem z Kold saO + You Corso

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago