The definition of this function is defined in this header file. I have included this header file because I am using one function i.e. But in this section, I will explain what is the logic behind this c program using the switch case statement in c. I have already mentioned what formulae we are going to use in this program. Printf("Enter values of all three sides\n") Printf("You have chosen Area of Triangle(All three Sides)\n") Printf("Area of Triangle is %.2f\n",area) Printf("You have chosen Area of Triangle(Base and Height)\n") Printf("You have chosen Area of Circle\n") C Program to Calculate Area of Circle, Rectangle and Triangle using a switch statement #include įloat area, radius, s1,s2,s3,base,height,sp Let’s see the c program first and then we will see the explanation. One way to calculate the area of a triangle by using the formula 1/2 * base * height and another way is to use heron’s formula. Similarly, if the user selects option 2 or 3 then he has to enter different values to calculate the area of triangles. Because this choice is for calculating the area of the circle.Īlso read: Floyd Triangle in C Programming If he selects choice 1, then he will be asked to enter the radius. He has to select any one choice from the above three choices. Why 3? Because we have been given three options and those are: 1. In the above, I have given three expected outputs. Heron’s Formula to Calculate Area of Triangle Output 3 – Heron’s Formula to Calculate Area of Triangle Output Explanation using Switch Case Output 2 – Area of the triangle on the basis of base and height. Area of Circle: Output 1 – Area of Circle Area of the triangle on the basis of base and height. Because there are three choices for the user. There are three outputs, I am showing here. So let’s see the output of this program first. In this c program, we have to write a c program to calculate the area of circles and triangles using a switch case statement. The sqrt means square root that we are going to use in this program. Here, S is semi-perimeter, s1, s2 and s3 are sides of the triangle and a is the area of a triangle. Perimeter means the addition of all the sides. Heron’s Formulaįirst, calculate the perimeter of the triangle. Where a is an area, b is the base and h is the height of the triangle. This formula is known as Heron’s formula. First, when we know only base and height and the other way is when you have been given values of three sides of the triangle. We can calculate the area of the triangle in two ways. In the above formula, a is area and r is radius of a circle. We need to calculate the area of the circle and triangle for this program using a switch case statement. In the switch case statement, you have multiple options and you can select one of them.Īlso read: Switch Case in C Formulae Used in this C Program In c programming, it is an alternative to an if-else ladder. Īll applications and games on our site are antivirus-tested using the most up-to-date signatures.Switch case in the c programming language is a very important concept. G-Switch 2 is distributed freely in the file type. It's still a lot of fun, and its funny soundtrack makes endless or multiplayer play fun, so if you're looking for simple yet fast reflex-based high-end gameplay on your desktop, G-Switch 2 is worth downloading. It differs significantly from the original game, although it seems to play smoothly. If this all sounds familiar, it's because it isn't. Some points on the track will speed you up, others will slow you down, and if you play in endless mode, everything is procedurally generated. If you hit something, it's not the end of the world, unless you get knocked out off-screen, and even then you just reboot at the last checkpoint until you get it right. As before, your character never stops running, so just press any key you want him to roll up and down the screen, run across the floor or ceiling (no matter which direction the path is going) and trying to avoid obstacles or fall to your death on your way to checkpoints that look like a force field. The game now offers even more possibilities with G-Switch 2, which keeps familiar gameplay intact, with sharpened visuals and an increased local multiplayer experience from six to eight. You were able to dodge obstacles and swim across chasms if you were fast enough. Long ago, we were introduced to the dynamic, gravity-changing world of G-Switch, a dynamic platformer in which a keystroke caused the gravity of your ever-running hero to flip, allowing him to run across the ceiling. G-Switch 2 is the second installment in the exciting G-Switch series.
0 Comments
Leave a Reply. |