Use switch statement to ask user to select between \"Hexagonal\" and \"Triangle\
ID: 3671022 • Letter: U
Question
Use switch statement to ask user to select between "Hexagonal" and "Triangle". Write two functions to plot both shapes, if user enters "triangle" then the triangle function should be called and plot the triangle. Similarly for hexagonal, in case of Triangle, AB and C, and C would be the moving corner for 50 times within appropriate limits of random numbers. In case of Hexagonal, F would be the moving corner for 50 times. At the end you should be able to display the distance between initial and final portions of moving node XY coordinate system.Explanation / Answer
#include<stdio.h>
int main()
{
char ch[10];
switch(ch) {
case 'triangle' :
int plotTriangle();
break;
case 'hexagonal' :
int plotHexagonal();
break;
default :
printf("Invalid choice");
}
return 0;
}
int plotTriangle() {
int a, b, c[];
/* Code for Implementation of triange*/
for(i=1; i<=50; i++) {
/* Condition for how the point 'c' in triangle ABC has to change */
}
return distance(c[1], c[50]);
}
int plotHexagonal() {
int a, b, c, d, e, f[];
/* Code for Implementation of Hexagon*/
for(i=1; i<=50; i++) {
/* Condition for how the point 'f' in hexagon ABCDEF has to change */
}
return distance(f[1], f[50]);
}
int distance(int a, int b){
/* Code to calculate distance between two points*/
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.