Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

switch instead of if else

$
0
0
First of all I made this in the iPad so it might not be in perfect coding but I was wondering if i could shorten the script with "switch" instead of "if....else" Also I will use Microsoft Visual C++ 2010 for the other errors I know I have. Many thanks in advance.
//run

#include <iostream>
#include <cmath>

label start:
cout << "After any error press q for ERROR n Help"
cout << "enter the sides in small,long,hypt format"
cin >> (small);
cin >> (long);
cin >> (hypt);
func (hypteq)
{
sqrt
{
sqr small + sqr long
}
}
int main()
{
 if {
small > hypt 
cout << "ERROR 1 Not a right triangle";
{
if cin << q
go to E1
}
} else {
goto ( long check)

label long check: {
if {
long > hypt
cout << "ERROR 2 Not a right triangle."
{
if cin << q
go to E2
}
} else {
goto checks0
}

label checks0: {
if small < 1
cout << "ERROR 3 Not a right triangle."
{
if cin << q
go to E3
}
} else {
goto checkl0
}

label checkl0: {
if long < 1
cout << "ERROR 4 Not a right triangle"
{
if cin << q
go to E4
}
} else {
goto (checkh)

label checkh: {
if hypt != hypteq
cout << "ERROR 5 not a right triangle"
{
if cin << q
go to E5
}
} else {
cout << hypeq
}

label E1:
cout << "small side bigger then hypt try again";
go to (start)

label E2: 
cout << "small size less then 1 try again";
goto (start)

label E3:
cout << "long side greater then hypt try again";
goto (start)

label E4:
cout << "long side less then 1 try again";
goto (start)

label E5:
cout: "hypt not equal to equation try again" ;
goto (start)

return = 0
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>