473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Switch blocks

the question is here
http://www.megaupload.com/?d=RY0AB70J

Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3. #include <cmath> 
  4. int main()
  5. {//variables defined here
  6. float a,b,E,x,g,h,y,w,q;
  7. int choice;
  8.  
  9. cout<<"Which equation would you like to evaluate";
  10. cout<<"\nPress 1 for this equation, y=10+(5a/3b)-b^2";
  11. cout<<"\nPress 2 for this equation, w=6x^5-15";
  12. cout<<"\nPress 3 for this equation, q=(3.0/4.0)h-7g/6";
  13. cout<<"\nPress 4 for the equation that's not here";
  14. cin>>choice;
  15.  
  16. switch (choice)
  17. {case (1):
  18. {cout<<"Value for a ";
  19. cin>>a;
  20. cout<<"Value for b ";
  21. cin>>b;
  22. y=10+((5*a)/(3.0*b))-(pow(b,2));
  23. cout<<"Value of y is ";
  24. }
  25. case (2):
  26. {cout<<"Value for x ";
  27. cin>>x;
  28. w=(6*pow(x,5))-15;
  29. cout<<"Value for w is";
  30. }
  31. case (3):
  32. {cout<<"Value for g ";
  33. cin>>g;
  34. cout<<"Value for h ";
  35. cin>>h;
  36. q=((0.75)*h)-((7*g)/6);
  37. cout<<E;
  38. }
  39. case (4):
  40. {cout<<"Sorry that's all I have for now.";
  41. }
  42. cout<<"In order to exit, please press any key. ";
  43. cin>>E;
  44.  
Nov 2 '08 #1
1 1408
oler1s
671 Expert 512MB
Don't put your question on megaupload, or any other site. You can type in a question here directly, and you should do so.

In general, give us a specific problem. Don't dump your code and run.
Nov 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: reneecccwest | last post by:
Hello, Aren't they same conditional statment to show the resut? but somehow "switch" condtional stmt always gets the default value when I excute? what did I wrong? <script language="JavaScript">...
21
by: Andy | last post by:
Can someone tell me if the following Switch...Case construct is valid? I'm wanting to check for multiple values in the Case statement without explicitly listing each values. So for example, will...
5
by: Neil Zanella | last post by:
Hello, Unlike in pre-C99 versions of C where variables can only be defined at the beginning of blocks, C99 allows variables to be defined in arbitrary places inside blocks. However, gcc 3.2.2...
12
by: junky_fellow | last post by:
Which is better using a switch statement or the if-then equivalent of switch ?
2
by: Guadala Harry | last post by:
After RTFM, I hope I have missed something: I would like to have a switch() statement process multiple input values the same way - but without having multiple case: blocks for multiple input values...
13
by: PeterZ | last post by:
Hi, Back to basics! My understanding is that the only way to exit a For-Next loop prematurely is with the 'break' keyword. How are you supposed to do that if you're inside a Switch...
0
by: Pegaso | last post by:
Hi... I have created a utility library with VC++ 7.1 which is used by a VB 6 client. The library creates a secondary thread of execution in order to listen for connections on a socket. The...
15
by: Benny Raymond | last post by:
I'm confused as to how fallthrough is limited in switch. For example the following works: string switch_test = "a"; switch (switch_test) { case "a": case "b": case "c": doSomething(a);
3
by: apandapion | last post by:
The following code snippet fails to compile with "a local variable named n is already defined in this scope." This makes me uncomfortable, but I could not tell you exactly why. My instincts are...
25
by: v4vijayakumar | last post by:
'continue' within switch actually associated with the outer 'while' loop. Is this behavior protable? int ch = '\n'; while (true) { switch(ch) { case '\n': cout << "test"; continue; } }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.