By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,129 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,129 IT Pros & Developers. It's quick & easy.

Can we call a function from a switch case??

P: 2
If yes, please guide, as how to call a function from a case of a switch loop.

Iam putting up the format, please just fill it if u know.......


Expand|Select|Wrap|Line Numbers
  1. switch(abc)
  2. {
  3. case 1:                        //call Function 1 here
  4.  
  5.  
  6. case 2:                        //call Function 2 here
  7.  
  8. default:xyz;
  9. }
  10.  
  11.  
  12.  
  13.  
  14. function 1( )
  15. {
  16. ....
  17. ....
  18. }
  19.  
  20. function 2( )
  21. {
  22. ...
  23. ...
  24. }

Thanks in Advance
Jan 3 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
Sorry if the question is too stupid :(

Though the prorgram works in other ways, but i want it like that.

I want to call a function from the switch, and the function asks, operates and puts the result.
Jan 3 '07 #2

Expert 100+
P: 1,510
If yes, please guide, as how to call a function from a case of a switch loop.

Thanks in Advance
yes. e.g.
Expand|Select|Wrap|Line Numbers
  1. switch(abc)
  2. {
  3. case 1:    function1(); break;                     //call Function 1 here
  4.  
  5. case 2:    function2(); break;                         //call Function 2 here
  6.  
  7. default:xyz;
  8. }
Jan 3 '07 #3

Post your reply

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